close all
m_max = 1000; eps = 0;
legend_cell = {};  % for the legend of the plot
k = 1;

for n = [8,16,32,64]
    % construct A
    e = ones(N,1); 
    A = spdiags([-0.5*e,2*e,-2*e], [-1 0 1], n,n);
    b = rand(n,1);
    x0 = zeros(n,1);
    [x,resvec,iter] = jacobi(A,b,x0,m_max,eps);
    semilogy( (0:iter),[1;resvec(1:iter)]);
    hold on
    str = ['n = ', num2str(n)];
    legend_cell{k} = str;
    k = k+1;
end

hold off
title('residual norms');
legend(legend_cell);

