Power Iteration Simulator Back
Numerical Linear Algebra Simulator

Power Iteration Simulator — Dominant Eigenvalue by Iteration

Iterate v ← Av/‖Av‖ on a 3x3 symmetric matrix to estimate the dominant eigenvalue and eigenvector. Read the eigenvalue from the Rayleigh quotient and feel how the ratio |lambda2/lambda1| sets the convergence speed.

Parameters
Iterations k
steps
Diagonal A[1,1]
Diagonal A[2,2]
Diagonal A[3,3]
Target matrix A
410
131
012
Off-diagonals are fixed (A[1,2]=A[2,3]=1, A[1,3]=0)
Initial vector v_0 = (1, 1, 1)/sqrt(3)
Results
Estimated dominant lambda1 (Rayleigh)
Reference lambda1 (3+sqrt(3))
Error |lambda_est − lambda_true|
Convergence ratio |lambda2/lambda1|
lambda_est per Iteration and Error Convergence

Top: lambda_est[k] (red) and lambda_true (gray dashed) / Bottom: log10|lambda_est[k]−lambda_true| (blue). Slope ≈ log10|lambda2/lambda1|

Theory & Key Formulas

Power iteration is the basic algorithm for finding the dominant eigenvalue (largest in absolute value) and its eigenvector of a matrix $A$ by repeated multiplication.

Basic iteration with normalization. $v_0$ is any starting vector:

$$v_{k+1} = \frac{A\,v_k}{\|A\,v_k\|_2}$$

Eigenvalue estimate by the Rayleigh quotient. Accuracy improves as $v_k$ approaches the eigenvector:

$$\lambda_k = \frac{v_k^{\!\top} A\,v_k}{v_k^{\!\top} v_k}$$

Convergence rate. The smaller the dominance ratio $r = |\lambda_2/\lambda_1|$, the faster:

$$|\lambda_k - \lambda_1| \;\sim\; r^{\,2k} \quad (\text{for symmetric } A)$$

Because this matrix is symmetric, all eigenvalues are real. With the default values the characteristic polynomial $\lambda^3 - 9\lambda^2 + 24\lambda - 18 = 0$ gives $\lambda_1 = 3+\sqrt{3} \approx 4.732$, $\lambda_2 = 3$, $\lambda_3 = 3-\sqrt{3} \approx 1.268$.

What is the Power Iteration Simulator

🙋
If you want eigenvalues of a matrix, you just solve the characteristic polynomial, right? Why bother with an iterative method like power iteration?
🎓
For 3x3 that works. But the matrices you meet in practice can be tens of thousands or millions of dimensions. At that scale, even forming the characteristic polynomial breaks down. Power iteration targets just the single dominant eigenvalue, and it only needs a matrix-vector product $Av$ each step. That is exactly what early Google PageRank did — it computed an eigenvector of the entire web graph this way.
🙋
Wait, PageRank really was power iteration? In the simulator, with 1 iteration lambda_est is way off, but with about 20 it lands right on the true value 4.732.
🎓
That is convergence in action. The Rayleigh quotient $v^\top A v / v^\top v$ gets sharper as $v$ approaches the eigenvector. Look at the bottom plot — the log of the error is a straight line. Its slope is the convergence ratio $|\lambda_2/\lambda_1|$; the smaller that ratio, the faster you go down. With the default matrix it is $3/4.732 \approx 0.634$, so each step shrinks the error by roughly a factor of 0.6.
🙋
When I push A[1,1] up to 10 with the slider, the convergence-ratio card drops and the error plot dives.
🎓
Right. The further the dominant eigenvalue stands above the rest, the happier power iteration is. Conversely, if the eigenvalues bunch together (ratio close to 1), even hundreds of steps barely help. In practice people use shifting (replace A by A − sigma I to change the relative ratio) or the Rayleigh-quotient shift (update sigma every step) to accelerate. All of those tricks rest on this one ratio.
🙋
What if I want all the eigenvalues, not just one?
🎓
That is where the QR algorithm enters. You can think of QR as 'running power iteration in every direction at once with re-orthogonalization'. So power iteration is the heart of QR too. The eig functions in LAPACK or NumPy use Hessenberg reduction plus shifted QR under the hood, and the theoretical backbone is exactly the simple iteration you are running right now.

Frequently Asked Questions

It is the right tool when only the dominant eigenvalue and eigenvector are needed. The classic example is Google PageRank: power iteration on the web's transition matrix gives the stationary distribution (the eigenvector for eigenvalue 1) used as page importance. In structural analysis, inverse power iteration (power iteration on A^-1) is used to approximate the lowest natural frequency. The first principal component in PCA is also obtained by power iteration on the covariance matrix.
Inverse iteration applies power iteration to A^-1, which yields the smallest eigenvalue in absolute value. Shifted inverse iteration iterates on (A − sigma I)^-1, extracting the eigenvalue closest to the shift sigma. So given even a rough estimate of the desired eigenvalue, you can recover any eigenpair to high accuracy. Each iteration costs one linear solve, but convergence is usually extremely fast.
The rate is governed by the ratio |lambda2/lambda1|; the closer it is to 1, the slower convergence becomes. Standard remedies are shifting (replace A by A − sigma I to alter the relative ratio), Rayleigh-quotient shifts (update sigma at every step to the current best estimate), or, if the trouble comes from repeated or complex eigenvalues, switching to a more general method such as the QR algorithm. If the initial vector happens to be orthogonal to the target eigenvector, in theory iteration cannot start, but rounding error always seeds the missing component in practice.
The QR algorithm is the general-purpose method for finding all eigenvalues simultaneously, and it can be understood as 'power iteration in every direction at once with re-orthogonalization'. The step A=QR followed by A←RQ implicitly uses the same convergence logic as power iteration while progressively triangularizing the matrix. Combined with shifts, Hessenberg reduction and double shifts, this is the workhorse of modern eigenvalue libraries such as LAPACK.

Real-World Applications

Search-engine page ranking: The original Google PageRank is power iteration on the transition matrix of the web. With billions of pages forming a giant sparse matrix, just a few dozen matrix-vector products give the stationary distribution. Power iteration's property "you never have to store A explicitly, only compute Av" is decisive at this scale.

Lowest mode of structural vibration: In vibration analysis of buildings, bridges and machines, the lowest natural frequency (smallest eigenvalue) governs seismic response and resonance. For the generalized eigenvalue problem Kx=λMx with stiffness K and mass M, shifted inverse iteration recovers exactly the eigenvalue you want at high speed. The Lanczos and subspace methods inside FEM packages are descendants of power iteration.

Principal component analysis and dimensionality reduction: PCA, ubiquitous as a preprocessing step in machine learning, amounts to extracting the leading eigenvalues and eigenvectors of the data covariance matrix. The first principal component is power iteration; subsequent components are obtained by combining power iteration with deflation (subtracting off the directions already found). The SVD used in recommender systems is also computed by power-iteration-style methods.

Stationary distribution of Markov chains: The eigenvector for eigenvalue 1 (the left eigenvector) of a transition probability matrix P represents the long-time state distribution. Whenever you want the equilibrium of a stochastic system — Monte Carlo simulations in physical chemistry, queueing analysis, hidden Markov models in NLP — power iteration or its generalization, the Arnoldi method, is at work.

Common Misconceptions and Cautions

The most common misconception is that "power iteration always converges to the largest eigenvalue". More precisely, it converges when the dominant eigenvalue is unique in absolute value and the initial vector is not orthogonal to its eigenvector. If the eigenvalues include a pair like ±lambda with equal absolute value but opposite sign, the iteration oscillates instead of converging. Real symmetric matrices have only real eigenvalues, and equal absolute values can only happen with opposite signs. Changing the diagonal in this simulator keeps A symmetric so the issue rarely arises here, but for general non-symmetric matrices you must watch for it.

Next is the assumption that "convergence depends only on the iteration count". In reality the ratio $r = |\lambda_2/\lambda_1|$ dominates, and a matrix with $r$ near 0.99 will still have substantial error after 1000 steps. In the simulator, push A[1,1] to 10 while keeping A[2,2] and A[3,3] at 1 to make the ratio small, and the accuracy improves by orders of magnitude after only about five iterations. When the diagonals are close, doubling the iteration count barely helps. The modern design answer is to shift the spectrum to improve the ratio.

Finally, do not confuse the Rayleigh quotient with the "componentwise estimate (Av_k)_i / (v_k)_i". In theory, once $v_k$ is exactly an eigenvector each component gives the same lambda. But while $v_k$ is still converging the components disagree and this estimator is unreliable. The Rayleigh quotient $v^\top A v / v^\top v$ minimizes a least-squares residual and returns the "best-fit eigenvalue", so it is typically accurate to second order in the eigenvector error. In implementations, always read off the eigenvalue with the Rayleigh quotient.