Eigen value and eigen vector using power method

Filter Course


Eigen value and eigen vector using power method

Published by: Dikshya

Published date: 19 Jul 2023

Eigen value and eigen vector using power method

Eigen value and eigen vector using power method

The power method is an iterative numerical technique used to find the dominant eigenvalue and its corresponding eigenvector of a square matrix. The dominant eigenvalue is the one with the largest absolute value, and its associated eigenvector is the one that corresponds to that eigenvalue.

The power method works as follows:

  1. Start with an initial guess for the dominant eigenvector, denoted as 'v'.
  2. Multiply the matrix 'A' (for which we want to find the dominant eigenvalue and eigenvector) by the initial guess vector 'v' to get a new vector 'Av'.
  3. Normalize the vector 'Av' to prevent it from growing too large or small. This involves dividing each component of 'Av' by the largest absolute value in 'Av', making the largest component equal to 1.
  4. Set 'v' equal to the normalized vector 'Av'.
  5. Repeat steps 2 to 4 for a sufficient number of iterations until 'v' converges to the dominant eigenvector.

To find the dominant eigenvalue, you can simply multiply the matrix 'A' with the final converged eigenvector 'v' and divide it by the eigenvector 'v'. The dominant eigenvalue 'λ' is given by:

λ = (A * v) / v

Illustration:

import numpy as np

def power_method(A, num_iterations):
    n = A.shape[0]  # Get the size of the square matrix
    v = np.random.rand(n)  # Generate a random initial guess for the eigenvector
    v = v / np.linalg.norm(v)  # Normalize the initial guess vector

    for _ in range(num_iterations):
        Av = A.dot(v)  # Multiply A with the current guess vector
        v = Av / np.linalg.norm(Av)  # Normalize the new vector

    eigenvalue = np.dot(A.dot(v), v) / np.dot(v, v)  # Calculate the dominant eigenvalue
    return eigenvalue, v

# Example usage:
A = np.array([[4, -1], [2, 1]])
num_iterations = 100
dominant_eigenvalue, dominant_eigenvector = power_method(A, num_iterations)

print("Dominant eigenvalue:", dominant_eigenvalue)
print("Dominant eigenvector:", dominant_eigenvector)

Note that the convergence of the power method can be slow, especially if the eigenvalue corresponding to the dominant eigenvector is close to other eigenvalues in magnitude. In such cases, other methods like the inverse power method or the QR algorithm might be more suitable.