function x=jacobi(A,b,x0,m)
n=size(A,1);
x_old=x0;
x_new=zeros(n,1);
for passo=1:m
    for i=1:n
        c=b(i);
        for j=1:i-1
            c=c-A(i,j)*x_old(j);
        end
        for j=i+1:n
            c=c-A(i,j)*x_old(j);
        end
        x_new(i)=c/A(i,i);
    end
    x_old=x_new;
    norm(b-A*x_new)
end
x=x_new;