- Asked 2/13
- 2074 Bhadra · 8 marks
- 2073 Magh · 8 marks
Power method pseudo-code
Short answer
Power method: start with non-zero vector x, iterate y = A*x, lambda = largest component of y, x = y/lambda. Repeat until |lambda - lambda_old| < tolerance. Output dominant eigenvalue lambda and eigenvector x.
Write a pseudo-code (algorithm) to determine the largest (dominant) eigenvalue and the corresponding eigenvector of a square matrix using the Power Method.
The power method finds the dominant eigenvalue (largest in magnitude) and its eigenvector. Repeated multiplication A·x makes the vector turn toward the dominant eigenvector, and the scale factor approaches the eigenvalue.
Pseudo-code
Algorithm: Power method
Input : n, matrix A[n][n], initial vector x[n] (non-zero,
e.g. all 1), tolerance e, max iterations N
Output: dominant eigenvalue lambda, eigenvector x
1. Read n, A, x, e, N
2. Set lambda_old = 0, k = 1
3. Repeat steps 4 to 11 while k <= N
4. y = A * x // y[i] = sum_j A[i][j]*x[j]
5. lambda = element of y with largest absolute value
6. If lambda = 0 then
print "Zero eigenvalue; try another x"; stop
7. For i = 1 to n do
x[i] = y[i] / lambda // scale
End for
8. If |lambda - lambda_old| < e then
9. print "Dominant eigenvalue =", lambda
10. print "Eigenvector =", x
stop
End if
11. lambda_old = lambda
k = k + 1
12. End repeat
13. Print "Not converged in N iterations"
14. Stop
Notes
- Convergence rate depends on the ratio |λ2/λ1| of the two largest eigenvalues; the smaller the ratio, the faster.
- The starting vector must have a component along the dominant eigenvector.
- Scaling by the largest component keeps numbers from overflowing.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Gauss-Jordan pseudo-code · Numerical Method, chapter 3 · asked 4×
- Bisection method pseudo-code · Numerical Method, chapter 2 · asked 3×
- False position pseudo-code · Numerical Method, chapter 2 · asked 2×
- Simpson 3/8 pseudo-code · Numerical Method, chapter 5
- Power method: 2,5,1 matrix · Numerical Method, chapter 3 · asked 4×
- Power method: 1,4,-1 matrix · Numerical Method, chapter 3 · asked 3×
- Algorithm/pseudo-code for software PID · Embedded System, chapter 7 · asked 3×
- Algorithm versus pseudo-code · Computer Programming, chapter 2
- Algorithm for largest and smallest · Computer Programming, chapter 2
- Algorithm and flowchart for largest · Computer Programming, chapter 2