function x = jacobi_S_1(a,b)
% Método de Jacobi para matriz a dispersa
%
 n=length(b);               % find n
 d=diag(a);                 % extract diagonal of a
 r=a-diag(d);               % r is the remainder
 x=zeros(n,1); k=0; sm=1;   % initialize vector x
 while sm>0.00001           % loop for Jacobi iteration
    y=(b-r*x)./d;
    sm=max(abs(x-y))/max(abs(y)); k=k+1;
    x = y;
 end
end