%n = 100;
%rand(1);
%A = ddrandom(n);
%lambda = 0.0382;

%A = ddbucky();
%[n, ~] = size(A);
%lambda = 1;

n1 = 32;
A = laplacian2d(n1);
n = n1^2;
lambda = 0.0092;

tol = 1.e-10;
itermax = 3500;

x = ones(n, 1);
b = rand(n, 1);

[x1, conv1] = myjacobi(A, b, x, tol, itermax);

niter = length(conv1);
nps = 1:niter;

semilogy(nps, conv1, 'r.-');
grid on
hold on
semilogy(nps, conv1(1)/4*exp(-lambda*nps), '--')
legend('Jacobi iterations', 'guide');
xlabel('Iteration number');
ylabel('|A*x - b|^2');
title('Convergence of Jacobi iteration process');


