Eigenvalue Lab

Interactive lab · Chapter 3, Linear Algebra · §3.5–3.6

Eigenvalue Lab

A refresher on eigenvalues and eigenvectors before we use them for Markov chains. Step 1 shows what an eigenvector is, using the matrices from §3.5. Step 2 shows why every stochastic matrix has dominant eigenvalue 1 (§3.6.2). Step 3 shows how the power method and the Rayleigh ratio find the eigenvector that goes with it (§3.5.6).

How it works and what to try

How it works: In three steps. (1) Drag a unit vector x around the circle and watch Ax: an eigenvector is a direction the matrix does not turn, and its eigenvalue is the stretch. The characteristic equation is solved alongside. (2) Edit a 3 × 3 stochastic matrix and check three facts: A1 = 1, Gerschgorin disks keep every eigenvalue inside the unit circle, and under mild assumptions 1 is the only eigenvalue on it. (3) Run the power method and watch the Rayleigh ratio converge to the dominant eigenvalue. Multiplying on the left gives the stationary distribution π.

Try this: Find both eigenvector directions of the book’s Example 3.15. Then try the rotation, which has none, and the deterministic 3-cycle, where three eigenvalues tie on the unit circle. Compare how fast the power method converges on Example 3.24 and on a chain where all states communicate. Each step has tasks with hidden answers.

Section numbers refer to Chapter 3 (Linear Algebra) of S. Keshav, Mathematical Foundations of Computer Networking, Addison-Wesley, 2012.

1

What an eigenvector is

Goal: see that an eigenvector is a direction the matrix does not turn, and that its eigenvalue is how much the matrix stretches it.

A square matrix A transforms a column vector x into another vector Ax (§3.5.1). Usually Ax points in a new direction. For a few special directions, A acts like multiplication by a scalar:

Ax = λx  (EQ 3.14). The nonzero vector x is an eigenvector, and the scalar λ is its eigenvalue. If λ is negative, Ax points the opposite way along the same line.

Drag the blue vector x around the unit circle and watch the orange Ax. Only the direction of x matters, because any multiple of an eigenvector is also an eigenvector. You can also edit A directly.

The plane: x and Ax
x (unit length) Ax eigenvector directions image of the unit circle

Matrix A
Characteristic equation |A − λI| = 0  (EQ 3.17)
Angle from x to Ax as x goes round the circle

Horizontal axis: the direction of x. Vertical axis: the angle from x to Ax. Click the plot to move x. The angle is 0° where Ax points the same way as x (a positive eigenvalue) and ±180° where it points the opposite way (a negative eigenvalue). Those crossings, marked in green, are the eigenvector directions. Each one appears twice, 180° apart, because x and −x lie on the same line.

Try it

Task 1.1With Example 3.15, drag x until Ax lines up with it. What is the slope of that line, and how much longer is Ax than x? Then find the second direction.

Show answer

The first direction is the line y = √2 x, at about 54.7°, with |Ax| / |x| = 4 + √72 ≈ 12.49. That is the eigenvector [1, √2]T of Example 3.15 and Figure 3.1.

The second is y = −√2 x. Along it, Ax points backwards and is about 4.49 times longer, so λ = 4 − √72 ≈ −4.49.

Task 1.2Switch to the doubling matrix, then to the rotation. How many eigenvector directions does each have, and why?

Show answer

Doubling. Every direction is an eigenvector with λ = 2, so the angle is 0° everywhere (§3.5.2).

Rotation. There are none. Every vector is turned by exactly 90°, so the angle never reaches 0° or 180°. The characteristic equation λ2 + 1 = 0 has roots ±i, and the eigenvectors [1, ±i]T are complex (Example 3.16).

Task 1.3Switch to the stochastic matrix, whose rows each sum to 1. Find the eigenvector with eigenvalue 1. Does its direction look familiar?

Show answer

It is the 45° line, the direction of [1, 1]T. Multiplying A by the all-ones vector adds up each row, and every row sums to 1, so A1 = 1. The other eigenvalue is 0.3, with eigenvector [3, −4]T. Step 2 shows that this holds for every stochastic matrix.

2

Why a stochastic matrix has dominant eigenvalue 1

Goal: follow the three facts in §3.6.2 on a matrix you can edit.

A (right) stochastic matrix has non-negative entries, and each of its rows sums to 1 (§3.6). Entry aij is the probability of moving from state i to state j. The spectral radius is the largest |λ|, and an eigenvalue of that magnitude is the dominant (or principal) eigenvalue (§3.5.3, §3.5.5).

every row sums to 1
Stochastic matrix A  (row = from, column = to)

Rows that do not sum to 1 are rescaled before use, so everything below always uses a stochastic matrix.

Fact 1 · 1 is always an eigenvalue

Each entry of A1 is a row sum, so A1 = 1 and λ = 1 with eigenvector 1 (the right eigenvector). A matrix and its transpose have the same eigenvalues (§3.5.3), so AT also has eigenvalue 1. Its eigenvector is usually not 1.

Fact 2 · no eigenvalue lies outside the unit circle
unit circle |λ| = 1 Gerschgorin disk of each row eigenvalues
Reading the picture

By Gerschgorin's theorem (§3.5.6), every eigenvalue lies in some disk centred on a diagonal entry ajj, with radius equal to the sum of the other entries in that row. For a stochastic matrix that radius is 1 − ajj. So any point λ in disk j satisfies

|λ| ≤ ajj + (1 − ajj) = 1.

Every disk sits inside the unit circle and touches it only at the point 1, as in Figure 3.2. Edit the diagonal of A and watch the disks change size while staying inside the circle.

Fact 3 · under mild assumptions, 1 is the only eigenvalue of magnitude 1

Putting the facts together: 1 is an eigenvalue, nothing is larger in magnitude, and (under the mild assumptions) nothing else ties with it. So 1 is the dominant eigenvalue. The stationary distribution π is the eigenvector that goes with it. As in the queueing notes and the Markov Chain Lab, we write π as a row vector, so πA = π: π is a left eigenvector of A. EQ 3.19 writes the same equation transposed, as ATπ = π, with π a column vector.

The other eigenvectors: modes that decay

What do the eigenvectors with smaller eigenvalues mean? Take a two-state chain, A = [1 − a, a; b, 1 − b]. Its eigenvalues are 1 and λ2 = 1 − a − b. The left eigenvector for 1 is π = [b, a] / (a + b). The left eigenvector for λ2 is v = [1, −1]. Its entries sum to zero, so it is not a distribution. It describes moving probability mass from state 2 to state 1.

Every starting distribution can be written as x0 = π + c v, where c is how far state 1 starts from its stationary share. Because πA = π and vA = λ2v,

xk = x0Ak = π + c λ2k v.

The stationary part never changes, and the imbalance along v is multiplied by λ2 at each step. With a small |λ2| the chain forgets where it started in a few steps. With |λ2| near 1 it remembers for a long time. With a negative λ2 the imbalance also flips sign at each step.

Pr(state 1) after k steps
xk(1) π(1) π(1) ± |c| |λ2|k
The decomposition, step by step

Each row is xk = π + (c λ2k) v. Only the imbalance c λ2k v changes from row to row.

Try it

Task 2.1In Example 3.24, set a11 to 0 and make the rows sum to 1 again. What happens to the first Gerschgorin disk? Can any eigenvalue now leave the unit circle?

Show answer

Disk 1 becomes centred at 0 with radius 1, so it is the whole unit disk. The bound |λ| ≤ 1 still holds, because the disk never extends beyond the unit circle. A diagonal entry of 0 is the worst case, and it only reaches the boundary.

Task 2.2Choose the deterministic 3-cycle. Which eigenvalues lie on the unit circle? Is 1 still the dominant eigenvalue in the sense §3.5.5 needs?

Show answer

All three eigenvalues are cube roots of unity: 1 and −½ ± (√3/2)i, each with magnitude 1. Eigenvalue 1 still exists, and π = [⅓, ⅓, ⅓] is still stationary. But two other eigenvalues tie with it in magnitude, so repeated multiplication never makes them die away. This periodic chain is one of the cases that the "mild assumptions" of Fact 3 rule out.

Task 2.3Choose the identity, then the two closed classes. How many times does λ = 1 appear, and what does that mean for π?

Show answer

The identity has λ = 1 three times, and the two-class matrix has it twice. Each closed class contributes its own stationary distribution, so π is no longer unique: any mixture of them is also stationary. Footnote 3 excludes such matrices for this reason.

Task 2.4In the panel on decaying modes, start with all the mass in state 1. For each of the three examples, how many steps does it take for the imbalance |c λ2k| to fall below 0.01? Why does the oscillating example still converge?

Show answer

We need |c| |λ2|k < 0.01. Fast mixing: c = 1 − 4/7 = 3/7, and (3/7)(0.3)k falls below 0.01 at k = 4. Slow mixing: c = 0.5, and 0.5 (0.9)k needs k = 38. Oscillating: c = 1 − 8/17 = 9/17, and (9/17)(0.7)k needs k = 12.

In the oscillating chain the imbalance changes sign at every step, so the probability of state 1 overshoots π(1) and swings back. Its magnitude still shrinks by 0.7 at each step, because |λ2| < 1. Only λ2 = −1 would make it swing forever, which is the periodic case from Task 2.2.

The general lesson is that each eigenvector other than π is a pattern of imbalance around π, and its eigenvalue says how quickly that pattern dies away. The largest of these, |λ2|, survives longest and sets how fast the chain mixes.

3

Finding the dominant eigenvector: the power method and the Rayleigh ratio

Goal: see why repeated multiplication exposes the dominant eigenvector, and how the Rayleigh ratio reads off its eigenvalue.

Write the starting vector as a combination of eigenvectors, x0 = c1x1 + c2x2 + …. Then Akx0 = c1λ1kx1 + c2λ2kx2 + … (§3.5.4–3.5.5). If |λ1| is strictly the largest, the other terms shrink relative to the first like |λ2/λ1|k. So, after rescaling, xk lines up with the dominant eigenvector x1. At each step the Rayleigh ratio

ρk = xkTAxk / xkTxk

asks: if xk were an eigenvector, what would its eigenvalue be? As xk lines up with x1, ρk → λ1. The power method thus returns the dominant eigenvector, and the Rayleigh ratio returns its eigenvalue.

Iterations

Rayleigh ratio ρk against k

The dashed line is the true dominant eigenvalue. The Rayleigh ratio is an estimate, not a bound. For a matrix that is not symmetric it can overshoot λ1 before settling, as the first ratio of 13 in Example 3.21 does.

For a stochastic matrix we want π, the left eigenvector, so we multiply on the left: xk+1 = xkA. Starting from a probability vector, this is exactly the evolution of the state distribution in §3.6.1, which is why the distribution of a Markov chain settles to π. Multiplying on the right, Axk, would converge to the all-ones vector from Fact 1, which says nothing about the chain. The Markov Chain Lab follows this process in detail on chains of up to eight states.

Try it

Task 3.1With Example 3.15's matrix, iterate three times and compare the Rayleigh ratios and rescaled vectors with Examples 3.21 and 3.22. How many iterations does it take to get within 0.1% of λ1 = 4 + √72?

Show answer

The ratios are 13, 12.090 and 12.604, and the rescaled vectors are [0.625, 1], [0.739, 1] and [0.696, 1], matching the book. (Example 3.21 rounds 4304/356 = 12.0899 down to 12.08.) The ratio is within 0.1% of 12.4853 from k = 5 on, at 12.4795. Convergence is fast here because |λ2/λ1| = 4.49/12.49 ≈ 0.36.

Task 3.2Pick the rotation matrix in step 1 and run the power method. What goes wrong?

Show answer

The vector keeps turning by 90° and never settles, and the Rayleigh ratio stays at 0. The two eigenvalues ±i have the same magnitude, so neither dominates and neither term in c1λ1kx1 + c2λ2kx2 dies away. The power method needs a strictly dominant eigenvalue.

Task 3.3Run the power method on Example 3.24, then on "all states communicate". Why does the first take so many more iterations?

Show answer

For Example 3.24, λ2 ≈ 0.970 is very close to 1, so the error shrinks by only about 3% per step. That reflects the chain: mass leaks slowly from states 1 and 2 into the absorbing state 3, and π = [0, 0, 1]. With all states communicating, |λ2| is much smaller and the method converges in a few steps. This is the book's point that the gap between the two largest eigenvalues sets the speed (§3.5.6).

What to take away

  1. An eigenvector is a direction that A does not turn: Ax = λx. The eigenvalues are the roots of |A − λI| = 0 and may be complex.
  2. Every stochastic matrix has eigenvalue 1, because its rows sum to 1, and no eigenvalue larger than 1 in magnitude, by Gerschgorin. Under mild assumptions 1 is the only eigenvalue on the unit circle, so it is dominant.
  3. Repeated multiplication amplifies the dominant eigenvector, and the Rayleigh ratio estimates its eigenvalue. For a stochastic matrix, multiplying on the left gives the stationary distribution π, with πA = π.