---
title: "Power method pseudo-code"
subject: "Numerical Method"
chapter: 3
key: "semester_4/numerical_method:power-method-algorithm"
source: https://www.bctengineer.com/q/semester_4/numerical_method/power-method-algorithm
site: BCT Engineering
---

# Power method pseudo-code

Numerical Method · Chapter 3: Solution of system of linear algebraic equations

- Asked in: 2074 Bhadra, 8 marks; 2073 Magh, 8 marks (asked 2 times)
- Video: [CHP11V2 THE POWER METHOD](https://www.youtube.com/watch?v=V6vSIifZGZs) — Zekeriya ALTAÇ
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/numerical_method/power-method-algorithm
- Whole chapter: https://www.bctengineer.com/md/semester_4/numerical_method/chapter-3

## Question

Write a pseudo-code (algorithm) to determine the largest (dominant) eigenvalue and the corresponding eigenvector of a square matrix using the Power Method.

## 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.

## Answer

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
```text
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.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Power method finds:
   A. The dominant eigenvalue and eigenvector
   B. All eigenvalues
   C. The smallest
   D. The determinant
   Answer: A. Largest in magnitude. (Key point: Purpose)

2. Each y = A x is scaled by:
   A. Its sum
   B. The component of largest absolute value
   C. Its first element
   D. The determinant
   Answer: B. Prevents overflow; the factor approximates lambda. (Key point: Scaling)

3. Speed depends on:
   A. Matrix size only
   B. |λ1|
   C. |λ2/λ1|; smaller is faster
   D. Tolerance only
   Answer: C. Ratio of two largest eigenvalues. (Key point: Convergence rate)

4. The starting vector must:
   A. Be zero
   B. Be orthogonal to it
   C. Be an eigenvector of λ2
   D. Have a component along the dominant eigenvector
   Answer: D. Otherwise it never converges to it. (Key point: Start vector)

## Related in Numerical Method

- [Gauss-Jordan pseudo-code](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Agauss-jordan-pseudocode) — Numerical Method, chapter 3, asked 4×
- [Bisection method pseudo-code](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Abisection-pseudocode) — Numerical Method, chapter 2, asked 3×
- [False position pseudo-code](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Afalse-position-pseudocode) — Numerical Method, chapter 2, asked 2×
- [Simpson 3/8 pseudo-code](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Asimpson-38-pseudocode) — Numerical Method, chapter 5
- [Power method: 2,5,1 matrix](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Apower-method-2-5-1) — Numerical Method, chapter 3, asked 4×
- [Power method: 1,4,-1 matrix](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Apower-method-1-4-minus1) — Numerical Method, chapter 3, asked 3×

## Related in other subjects

- [Algorithm/pseudo-code for software PID](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Apid-software-algorithm) — Embedded System, chapter 7, asked 3×
- [Algorithm versus pseudo-code](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aalgorithm-vs-pseudocode) — Computer Programming, chapter 2
- [Algorithm for largest and smallest](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Adefine-algorithm-largest-smallest) — Computer Programming, chapter 2
- [Algorithm and flowchart for largest](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aalgorithm-flowchart-largest-n) — Computer Programming, chapter 2
