
function jacobi_script

% definizione matrice A
A=zeros(20);
for k=1:20
    A(k,k)=8;
    if k > 1
        A(k,k-1)=-1;
        A(k-1,k)=-1;
    end
end

% definizione termine noto
b=ones(20,1);

% iterazioni del metodo di Jacobi
x0=zeros(size(b)); toll=10^(-12); nmax=10000;
[xv,res,flag]=jacobi(A,b,x0,toll,nmax);

semilogy(1:length(res),res,'k-');
saveas(gcf, 'figura', 'jpg');

fprintf('\n \n \t res(1): %1.6e',res(1));
fprintf('\n \t res(end): %1.6e',res(end));
fprintf('\n \t length(res): %10.0f \n \n',length(res));