% eigen1.m --- power method format long a=[1 1 1;1 2 2;1 2 3] eigen=eig(a) x=ones(3,1); maxiter=10; r=zeros(maxiter,1); for k=1:maxiter y=a*x; x=y/norm(y); r(k)=x'*(a*x); end r error=r-max(eigen) clf semilogy(1:maxiter,abs(error))