function [x,k]=Gauss_Seidel_1_1(A,b)
% Resolución de Ax=b por Gauss-Seidel
%
 n=size(A,1); x=zeros(n,1); sm=1; k=0;
 while sm>0.001
    k=k+1; sm=0;
    for i=1:n
       j=[1:i-1 i+1:n];
       xi=(b(i)-A(i,j)*x(j))/A(i,i);
       sm=max(abs(x(i)-xi),sm);
       x(i)=xi;
    end
    sm=sm/max(abs(x));
 end
end