function [x, flg] = InversePowerMethod(A,sigma,x0,Iter,tol) % % This code performs an inverse power iteration % Written by Ming Gu for Math 128B, Spring 2009 % % flg = 1 indicates failure to converge within % Iter iterations. % x = x0/norm(x0); n = length(x0); flg = 1; for k = 1:Iter x = (A-sigma * eye(n)) \ x; x = x/norm(x); lambda = x'*(A*x); if (norm(A*x-lambda*x)<=tol) flg = 0; end end