power method for eigenvalues in matlab

To compute the power method for the dominant eigenvalue of a matrix in MATLAB, follow these steps:

  1. Define the matrix A.
  2. Randomly initialize a column vector x with probability distribution of your choice.
  3. Set an initial guess for the eigenvalue, lambda.
  4. Set the maximum number of iterations, maxIter, and the convergence tolerance, tol.
  5. Perform the power iteration until convergence or until maxIter is reached:
main.m
for k=1:maxIter
    % Compute y = A*x
    y = A*x;
    % Compute the new eigenvalue estimate
    lambda_new = x'*y/(x'*x);
    % Normalize y
    x = y/norm(y);
    % Check for convergence
    if abs(lambda_new-lambda) < tol
        break;
    end
    lambda = lambda_new;
end
276 chars
14 lines
  1. The final value of lambda is the estimate for the dominant eigenvalue of A, and x is an eigenvector associated with this eigenvalue.

Note that this method assumes that A has a unique dominant eigenvalue with a corresponding eigenvector that can be represented as a linear combination of the columns of x. If A does not meet these assumptions, then the convergence of the power iteration is not guaranteed.

related categories

gistlibby LogSnag