Published by: Dikshya
Published date: 19 Jul 2023
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:
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.