Here is an implementation of the Power Method with Deflation in MATLAB:
main.m476 chars24 lines
The function takes a square matrix A
, a tolerance level tol
, and a maximum number of iterations maxiter
as inputs. It initializes a starting vector x
and old eigenvalue lambda_old
. It then iterates to find the biggest eigenvalue and the corresponding eigenvector. After each iteration, it updates the matrix A
by removing the row and column corresponding to the eigenvector previously found. This process is repeated until the desired tolerance or maximum number of iterations is reached. Finally, it returns the computed eigenvalue and eigenvector.
Note that this implementation assumes that A
has distinct eigenvalues. If A
has repeated eigenvalues, then additional modification is required to the code.
gistlibby LogSnag