No BSD License  

Highlights from
Numerical Methods using Matlab, 2e

image thumbnail
from Numerical Methods using Matlab, 2e by John Penny
Companion Software

[lam,u]=eiginv(A,mu,tol)
function [lam,u]=eiginv(A,mu,tol)
% Determines eigenvalue of A closest to mu with a tolerance tol.
%
% Sample call: [lam,u]=eiginv(A,mu,tol)
% lam is the eigenvalue and u the corresponding eigenvector.
%
[n,n]=size(A); err=100*tol;
B=A-mu*eye(n,n);
u0=ones(n,1); iter=0;
while err>tol
  v=B\u0; f=1/max(v);
  u1=f*v; err=max(abs(u1-u0));
  u0=u1; iter=iter+1;
end
u=u0; iter, lam=mu+f;

Contact us at files@mathworks.com