function [x,k,nr]=Jacobi(A,b,toll)
P=diag(A);
N=diag(P)-A;
x=b;
for k=1:1000
    %x=P\(b+N*x);
    x=(b+N*x)./P;
    r=b-A*x;
    nr=norm(r);
    if nr<toll
        return
    end
end