function [v,lambda,info] = inverse_iteration(A,u)

% function [v,lambda,info] = inverse_iteration(A,u)
% eigenvector v close to u and eigenvalue lambda of A  

TOL = 10^(-10); MAX_IT = 100; 
u = u/norm(u);

for i = 1:MAX_IT;
   v = A*u;
   lambda = v'*u;
   v = (A - lambda*eye(size(A))) \ u;
   v = v/norm(v);
   if norm(u - sign(u'*v)*v) < TOL; 
      break;
   end;
   u = v;
end;

info.error = norm(A*u - lambda*u) / norm(A(:),inf);
info.steps = i;

