% m3_CGconvergence.m - explore CG convergence A = diag(100:199); b = ones(100,1); x = cg(A,b); whos x(1:4) A = diag( sparse(1000000:1999999) ); b = ones(1000000,1); x = cg(A,b); whos x(1:4) % - - - - - - - - - - - - - - - - - [pause] A = randn(1000); A = A'*A; b = ones(1000,1); kappa = cond(A) e = eig(A); max(e)/min(e) sqrt(kappa) cg(A,b); A = A + 100*eye(1000); kappa = cond(A) sqrt(kappa) cg(A,b);