function x=seidel(A,b,x0,k) [n,m]=size(A) for i=1:n B(i,:)=A(i,:)/(-A(i,i)) B(i,i)=0 c(i)=b(i)/A(i,i) endfor c=c' q=norm(B,inf) if q<1 & n==m for i=1:k i x=zeros(n,1) x(1)=B(1,:)*x0+c(1); for j=2:n x(j)=B(j,1:j-1)*x(1:j-1)+B(j,j:n)*x0(j:n)+c(j); endfor x x0=x endfor else disp('the conditions are not satisfied') endif endfunction