---
title: "Eigenvalues: power and inverse iteration"
heading: Multiply by the matrix until only one direction is left
eyebrow: "A13 · Lesson 30 · Eigenvalues: power and inverse iteration"
xp: 40
---

::: hook
The lowest resonance of a structure, the slowest decay of a thermal network, the steady state of a Markov chain, the ranking of web pages: each is one particular eigenvalue and eigenvector of a large matrix, and nobody computes all the others to get it. **Power iteration** just multiplies a vector by the matrix again and again. Every component shrinks or grows by its own eigenvalue, so the one with the largest takes over. **Inverse iteration** does the same with $(A - \sigma I)^{-1}$, which picks out the eigenvalue nearest any shift σ you choose, and converges very fast when σ is close.
:::

::: play
- The matrix has eigenvalues 1 and r, with the dominant eigenvector at angle θ (the orange arrow). The dots are the power iterates $v_k = A^kv_0/\lVert A^kv_0\rVert$, starting from $v_0 = (1, 0)$.
- With r = 0.6 the dots swing onto the arrow within a few steps: each step shrinks the other component by $\lvert r\rvert$.
- Push r toward ±0.95: the eigenvalues are nearly equal in size and convergence crawls. With r negative the dots alternate sides of the arrow, like a spiraling fixed-point iteration.
:::
:::

```sim plot
view: complex
range: 1.3
slider: t = 0..90 step 1 = 60 °
slider: r = -0.95..0.95 step 0.05 = 0.6
curve: exp(j*u) | over: u = 0..2*pi | dashed
arrow: exp(j*t*pi/180) | label: dominant eigenvector | color: ch3
dot: ((cos(t*pi/180)^2 + sin(t*pi/180)^2*r^0) + j*(sin(t*pi/180)*cos(t*pi/180)*(1 - r^0)))/abs((cos(t*pi/180)^2 + sin(t*pi/180)^2*r^0) + j*(sin(t*pi/180)*cos(t*pi/180)*(1 - r^0))) | label: v₀
dot: ((cos(t*pi/180)^2 + sin(t*pi/180)^2*r^1) + j*(sin(t*pi/180)*cos(t*pi/180)*(1 - r^1)))/abs((cos(t*pi/180)^2 + sin(t*pi/180)^2*r^1) + j*(sin(t*pi/180)*cos(t*pi/180)*(1 - r^1))) | label: v₁
dot: ((cos(t*pi/180)^2 + sin(t*pi/180)^2*r^2) + j*(sin(t*pi/180)*cos(t*pi/180)*(1 - r^2)))/abs((cos(t*pi/180)^2 + sin(t*pi/180)^2*r^2) + j*(sin(t*pi/180)*cos(t*pi/180)*(1 - r^2))) | label: v₂
dot: ((cos(t*pi/180)^2 + sin(t*pi/180)^2*r^3) + j*(sin(t*pi/180)*cos(t*pi/180)*(1 - r^3)))/abs((cos(t*pi/180)^2 + sin(t*pi/180)^2*r^3) + j*(sin(t*pi/180)*cos(t*pi/180)*(1 - r^3)))
dot: ((cos(t*pi/180)^2 + sin(t*pi/180)^2*r^4) + j*(sin(t*pi/180)*cos(t*pi/180)*(1 - r^4)))/abs((cos(t*pi/180)^2 + sin(t*pi/180)^2*r^4) + j*(sin(t*pi/180)*cos(t*pi/180)*(1 - r^4)))
dot: ((cos(t*pi/180)^2 + sin(t*pi/180)^2*r^5) + j*(sin(t*pi/180)*cos(t*pi/180)*(1 - r^5)))/abs((cos(t*pi/180)^2 + sin(t*pi/180)^2*r^5) + j*(sin(t*pi/180)*cos(t*pi/180)*(1 - r^5)))
dot: ((cos(t*pi/180)^2 + sin(t*pi/180)^2*r^6) + j*(sin(t*pi/180)*cos(t*pi/180)*(1 - r^6)))/abs((cos(t*pi/180)^2 + sin(t*pi/180)^2*r^6) + j*(sin(t*pi/180)*cos(t*pi/180)*(1 - r^6)))
dot: ((cos(t*pi/180)^2 + sin(t*pi/180)^2*r^7) + j*(sin(t*pi/180)*cos(t*pi/180)*(1 - r^7)))/abs((cos(t*pi/180)^2 + sin(t*pi/180)^2*r^7) + j*(sin(t*pi/180)*cos(t*pi/180)*(1 - r^7)))
dot: ((cos(t*pi/180)^2 + sin(t*pi/180)^2*r^8) + j*(sin(t*pi/180)*cos(t*pi/180)*(1 - r^8)))/abs((cos(t*pi/180)^2 + sin(t*pi/180)^2*r^8) + j*(sin(t*pi/180)*cos(t*pi/180)*(1 - r^8))) | label: v₈
readout: error shrinks per step by |λ₂/λ₁| = abs(r)
readout: steps for 6 digits = 6/log(1/abs(r))
```

::: predict
## A matrix has eigenvalues 3 and 1. About how many power iterations does it take to get the dominant eigenvector to 6 digits?

- [ ] 2
- [x] 13
- [ ] 1000
- [ ] It never converges

::: reveal
About 13: each step shrinks the unwanted component by $\frac13$, gaining $\log_{10}3 = 0.48$ digits, and $6/0.48 = 12.6$. The eigenvalue from the Rayleigh quotient converges twice as fast for a symmetric matrix.
:::
:::

::: nameit
## Power iteration

Start with any $v_0$ and repeat

$$w = Av_k, \qquad v_{k+1} = \frac{w}{\lVert w\rVert}$$

Writing $v_0 = \sum c_iu_i$ in eigenvectors, $A^kv_0 = \sum c_i\lambda_i^ku_i$. If $\lvert\lambda_1\rvert > \lvert\lambda_2\rvert \ge \cdots$ and $c_1 \ne 0$, the direction converges to $u_1$ with the error shrinking by $\left\lvert\frac{\lambda_2}{\lambda_1}\right\rvert$ per step.

The eigenvalue comes from the **Rayleigh quotient** $\frac{v^TAv}{v^Tv}$; for a symmetric A its error is the square of the vector's error, $\left\lvert\frac{\lambda_2}{\lambda_1}\right\rvert^{2k}$.

## Inverse iteration

The eigenvalues of $(A - \sigma I)^{-1}$ are $\frac{1}{\lambda_i - \sigma}$, largest for the $\lambda_i$ nearest σ. Power iteration on it (factor $A - \sigma I$ once, then solve each step) converges to that eigenvector with ratio

$$\frac{\lvert\lambda_{near} - \sigma\rvert}{\lvert\lambda_{next} - \sigma\rvert}$$

With σ = 0 it finds the smallest eigenvalue: the lowest mode of a network. Updating σ to the latest Rayleigh quotient each step (**Rayleigh quotient iteration**) converges cubically for symmetric matrices.

## Uses and limits

Power iteration needs only products Av, so it works on huge sparse matrices; PageRank is power iteration on the web's link matrix. It finds one eigenvalue at a time (deflate or use subspace iteration for more), and it stalls when the two largest are close in size. For all eigenvalues of a moderate matrix, use the QR algorithm (lesson 31).
:::

::: example
## Apply power iteration to $\begin{pmatrix}2 & 1\\ 1 & 2\end{pmatrix}$ from (1, 0).

::: solution
1. **The iterates.** Unnormalized, they are (2, 1), (5, 4), (14, 13): heading for (1, 1), the eigenvector of 3.
2. **The Rayleigh quotients.** They are 2.8, 2.976, 2.997, with errors 0.2, 0.024, 0.0027.
3. **The rate.** The errors shrink by $\frac19$ each step, the square of the ratio $\frac13$.

**Answer:** the iterates head for (1, 1), and the Rayleigh quotients 2.8, 2.976, 2.997 approach the eigenvalue 3, their error shrinking ninefold each step.
:::
:::

::: example
## For the same matrix, inverse iteration with σ = 0.9: how fast does it converge, and to what?

::: solution
1. **Which eigenvalue.** The nearest eigenvalue to 0.9 is 1, with eigenvector (1, −1).
2. **The rate.**
   $$\frac{\lvert 1 - 0.9\rvert}{\lvert 3 - 0.9\rvert} = 0.048$$
   per step: over 1.3 digits each time.

**Answer:** it converges to the eigenvalue 1, with eigenvector (1, −1), gaining over 1.3 digits a step.
:::
:::

::: example
## A machine is up or down each hour: from up it fails with probability 0.1, and from down it is repaired with probability 0.2. Find its long-run availability by power iteration.

::: solution
1. **The transition matrix.** Acting on the probability vector (up, down), it is
   $$P = \begin{pmatrix}0.9 & 0.2\\ 0.1 & 0.8\end{pmatrix}$$
2. **Its eigenvalues.** The largest is 1, with eigenvector $\left(\frac23, \frac13\right)$, and the other is $1 - 0.1 - 0.2 = 0.7$.
3. **Iterate.** From (1, 0) power iteration gives (0.9, 0.1), (0.83, 0.17), (0.781, 0.219), …, approaching $\frac23$ with the error shrinking by 0.7 each hour.
4. **A bigger example.** Search engines' PageRank is this same iteration on a matrix with billions of rows.

**Answer:** the availability is $\frac23$, 66.7%.
:::
:::

::: check
given: l1 = 5 | 10 | -4; l2 = 2 | 3 | 1
answer: abs(l2/l1)
tolerance: 0.5%

## A matrix's two largest eigenvalues are {l1} and {l2}. By what factor does power iteration shrink the eigenvector error each step?

::: right
Right. $\lvert\lambda_2/\lambda_1\rvert$ = {answer}.
:::

::: misses
- [abs(l1/l2)] Invert it: the factor is below 1.
- [any] Not yet. $\lvert\lambda_2/\lambda_1\rvert$.
:::
:::

::: check
given: q = 0.5 | 0.9 | 0.99; d = 6 | 10
answer: d/log(1/q)
tolerance: 1%

## With $\lvert\lambda_2/\lambda_1\rvert$ = {q}, about how many power iterations give the eigenvector to {d} digits?

::: right
Right. $d/\log_{10}(1/q)$ = {answer}.
:::

::: misses
- [d/ln(1/q)] Decimal digits: use $\log_{10}$.
- [any] Not yet. Each step gains $\log_{10}(1/q)$ digits.
:::
:::

::: check
given: a = 2 | 4; b = 1 | 3; x = 1 | 2; y = 1 | 3
answer: (a*x^2 + 2*b*x*y + a*y^2)/(x^2 + y^2)
tolerance: 0.1%

## What's the Rayleigh quotient of v = ({x}, {y}) for $\begin{pmatrix}\given{a} & \given{b}\\ \given{b} & \given{a}\end{pmatrix}$?

::: right
Right. $\frac{v^TAv}{v^Tv}$ = {answer}.
:::

::: misses
- [a*x^2 + 2*b*x*y + a*y^2] Divide by $v^Tv$.
- [any] Not yet. $\frac{v^TAv}{v^Tv}$.
:::
:::

::: check
given: s = 0.9 | 2.8 | 5.2; l1 = 1; l2 = 3; l3 = 6
answer: step(2 - s)*abs(l1 - s)/abs(l2 - s) + step(s - 2)*step(4.5 - s)*abs(l2 - s)/abs(l1 - s) + step(s - 4.5)*abs(l3 - s)/abs(l2 - s)
tolerance: 0.5%

## A matrix has eigenvalues {l1}, {l2} and {l3}. Inverse iteration uses the shift σ = {s}. What's its convergence ratio per step?

::: right
Right. Nearest eigenvalue's distance over the next nearest's: {answer}.
:::

::: misses
- [any] Not yet. $\frac{\lvert\lambda_{near} - \sigma\rvert}{\lvert\lambda_{next} - \sigma\rvert}$.
:::
:::

::: check
given: a = 2 | 3; b = 1 | 2; x = 1 | 3; y = 2 | 5
answer: a*x + b*y
tolerance: 0.1%

## One power step: what's the first component of Av for $A = \begin{pmatrix}\given{a} & \given{b}\\ \given{b} & \given{a}\end{pmatrix}$ and v = ({x}, {y})?

::: right
Right. {answer}.
:::

::: misses
- [a*x + b*x] The second entry of the row multiplies the second component of v.
- [any] Not yet. Row 1 of A times v.
:::
:::

::: check
kind: choice

## You want the eigenvalue of a large sparse matrix closest to 5. What should you do?

- [ ] Power iteration on A
- [x] Inverse iteration with σ near 5: factor $A - 5I$ once and solve each step
- [ ] Power iteration on $A^2$
- [ ] Compute every eigenvalue and pick

::: misses
- [1] That finds the largest in size, not the one near 5.
- [3] Squaring keeps the same dominant one.
- [4] Far more work than needed for a large matrix.
:::
:::

::: check
kind: parts
given: p = 0.1 | 0.3; q = 0.2 | 0.4

## A two-state chain leaves state 1 with probability {p} and state 2 with probability {q} each step.

::: part
answer: q/(p + q)
tolerance: 0.5%

### What fraction of the time is it in state 1, in the long run?

::: misses
- [p/(p + q)] That's state 2's share.
- [any] The eigenvector for eigenvalue 1.
:::
:::

::: part
answer: 1 - p - q
tolerance: 0.5%

### By what factor does power iteration's error shrink each step?

::: misses
- [any] The second eigenvalue, $1 - p - q$.
:::
:::
:::

::: check
kind: derivation
vars: a = 1..5, b = -2..2, d = 1..5, t = -2..2

## The symmetric matrix $\begin{pmatrix}a & b\\ b & d\end{pmatrix}$ and the vector v = (1, t).

::: step
answer: (a + 2*b*t + d*t^2)/(1 + t^2)

### What is the Rayleigh quotient $\frac{v^TAv}{v^Tv}$?
:::

::: right
Right. Its largest value over t is the largest eigenvalue, and an error of ε in v gives an error of only about ε² in the quotient.
:::
:::

::: explain
## Why does repeated multiplication by A turn almost any starting vector into the dominant eigenvector?

::: model
Any starting vector is a combination of A's eigenvectors. Multiplying by A multiplies each eigenvector's share by its own eigenvalue, so after k multiplications each share has been scaled by $\lambda_i^k$. The share belonging to the eigenvalue of largest size grows fastest (or shrinks slowest), and relative to it every other share shrinks by a factor $\lvert\lambda_i/\lambda_1\rvert^k$. After normalizing, only that one direction is left. The method fails only if the start has exactly no component along the dominant eigenvector, and rounding errors usually supply one anyway.
:::
:::

::: practice

::: check
given: l1 = 8 | -6; l2 = 7 | 2
answer: abs(l2/l1)
tolerance: 0.5%

## Power-iteration ratio for {l1} and {l2}?

::: misses
- [any] $\lvert\lambda_2/\lambda_1\rvert$.
:::
:::

::: check
given: q = 0.3 | 0.95; d = 8 | 12
answer: d/log(1/q)
tolerance: 1%

## Iterations for {d} digits at ratio {q}?

::: misses
- [any] $d/\log_{10}(1/q)$.
:::
:::

::: check
given: a = 5 | 1; b = 2 | 4; x = 2 | 1; y = 1 | 4
answer: (a*x^2 + 2*b*x*y + a*y^2)/(x^2 + y^2)
tolerance: 0.1%

## Rayleigh quotient of ({x}, {y}) for $\begin{pmatrix}\given{a} & \given{b}\\ \given{b} & \given{a}\end{pmatrix}$?

::: misses
- [any] $\frac{v^TAv}{v^Tv}$.
:::
:::
:::
