function x=jacobi_controllo(A,b,x0,epsilon)
n=size(A,1);
x_old=x0;
x_new=zeros(n,1);
passo=0;
while norm(A*x_new-b)/(norm(b)+norm(A)*norm(x_new)) > epsilon
    passo=passo+1;
    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)
    if passo >500
        break
    end
end
x=x_new;