A matrix bends almost every arrow it touches. A precious few it merely stretches. Those special directions — and the numbers that say how much they stretch — are the secret skeleton of stability, PCA, and Google's PageRank.
A matrix is a machine that eats an arrow and spits out a different arrow. Feed it the arrow pointing east; it might hand you back an arrow pointing north-east, longer than before. Feed it a different arrow; it twists that one somewhere else entirely. In general a matrix does two things at once to whatever you give it: it rotates the arrow (changes its direction) and it stretches or shrinks it (changes its length).
Here is the surprise that this entire lesson is built around. For almost any matrix, there exist a few special arrows that the matrix refuses to rotate. It still stretches them — maybe doubles them, maybe flips them, maybe squashes them to a third of their length — but it leaves them pointing along exactly the same line they started on. They come out parallel to how they went in.
Why should you care about a few arrows that happen not to turn? Because they are the matrix's natural grain — like the grain in a plank of wood. Push along the grain and the wood behaves simply. Push across it and things get complicated. If you describe any motion in terms of these special directions, the messy rotating-and-stretching machine collapses into something almost embarrassingly simple: just independent stretching, one number per direction.
That simplification is why eigenvalues run through the spine of so much engineering. Whether a spring-mass system settles down or shakes itself apart is decided by eigenvalues. The directions PCA picks to compress your data are eigenvectors. The steady-state importance score PageRank assigns to a web page is an eigenvector. We will meet all three by the end. But first, just watch the phenomenon.
Drag the blue input arrow around the circle. The blue arrow is what you feed in; the orange arrow is what the matrix A = [[2, 1], [1, 2]] hands back. Watch the faint angle between them. At two special angles the angle snaps to zero — input and output point the same way. Those are the eigenvectors.
Play with it until you feel it. Almost everywhere, the orange output peels away from the blue input — the matrix is rotating your arrow. But at two angles (for this matrix, the 45° line and the 135° line) the orange arrow lies exactly on top of the blue line, only longer or shorter. The matrix gave up rotating and just stretched. Notice the stretch is bigger on the 45° line than on the 135° line — that difference in stretch is the difference between the two eigenvalues.
Chapter 0 gave you the picture. Now let's pin it down with symbols, because the picture is an equation in disguise. “The matrix A leaves the direction v unchanged, only stretching it by some factor” translates literally into:
Read it slowly, left to right. On the left, A·v means “run the vector v through the matrix machine” — the rotating-and-stretching operation. On the right, λ·v means “take the very same vector v and just scale it by the single number λ” — pure stretching, no rotation. The equation says those two operations land in the same place. The matrix did nothing the scalar couldn't do.
Here every symbol, defined once and for all: A is a square matrix (n×n), our transformation machine. v is the eigenvector — a non-zero direction (an n-component column). λ (the Greek letter lambda) is the eigenvalue — a single number, the stretch factor for that direction. A negative λ means the arrow flips to point backwards; a λ between 0 and 1 means it shrinks; a λ greater than 1 means it grows.
The fastest way to own the definition is to test it. Take the matrix from Chapter 0,
and let's test the candidate direction v = [1, 1] (the 45° arrow). Multiply A by v, one row at a time. Row 1 of A is [2, 1], so the top entry of A·v is 2×1 + 1×1 = 2 + 1 = 3. Row 2 of A is [1, 2], so the bottom entry is 1×1 + 2×1 = 1 + 2 = 3. Therefore:
That's a perfect match to the pattern A·v = λ·v with λ = 3. The output [3, 3] is just the input [1, 1] tripled — same direction, stretched by 3. So [1, 1] is an eigenvector and its eigenvalue is 3. The 45° line you snapped to in Chapter 0 grows by a factor of three.
Now the other candidate, v = [1, −1] (the 135° arrow). Top entry: 2×1 + 1×(−1) = 2 − 1 = 1. Bottom entry: 1×1 + 2×(−1) = 1 − 2 = −1. So:
Another match, this time with λ = 1. The 135° line is left completely fixed (stretched by 1, i.e. not at all). Two eigenvectors, two eigenvalues: 3 and 1. Exactly what the simulation showed — one direction stretched hard, the other barely touched.
To feel what a non-eigenvector looks like, try v = [1, 0] (pointing east). Top: 2×1 + 1×0 = 2. Bottom: 1×1 + 2×0 = 1. So A·[1,0] = [2, 1]. There is no single number λ with λ·[1,0] = [2,1], because [2,1] is not a multiple of [1,0] — it has tilted upward. East is not an eigenvector; the matrix rotated it. This is the common case.
One subtlety worth nailing now: if v is an eigenvector, so is 2v, and 10v, and −v. Scaling v doesn't change the equation — A·(2v) = 2·(A·v) = 2·(λv) = λ·(2v). So eigenvectors come as entire lines through the origin, not single points. We usually pick a convenient representative, often the unit-length one. The eigenvalue, though, is pinned: the stretch factor 3 is 3 no matter how long the arrow you draw along that line.
python import numpy as np A = np.array([[2., 1.], [1., 2.]]) # Test a candidate by hand: is the output a scalar multiple of the input? v = np.array([1., 1.]) out = A @ v # [3, 3] ratios = out / v # [3, 3] -> all equal -> eigenvector! print(out, ratios) # [3. 3.] [3. 3.] v2 = np.array([1., 0.]) print(A @ v2 / v2) # [2. inf] -> ratios DIFFER -> NOT an eigenvector
inf in the last line is just 2÷0 from the east arrow — a flag that the ratios cannot agree.So far we've only been able to check a guess. That's fine when someone hands you a candidate, but useless if you're staring at a fresh matrix with no idea which directions are special. We need a way to find the eigenvalues from scratch. The trick is a beautiful piece of algebraic judo.
Start from the definition and shove everything to one side:
We'd love to factor out v, but A is a matrix and λ is a number — you can't subtract a number from a matrix directly. The fix is the identity matrix I (1's on the diagonal, 0's elsewhere), the matrix that does nothing: I·v = v. So λ·v is the same as λI·v, and now everything is a matrix:
Look hard at (A − λI)·v = 0. It says: the matrix (A − λI) takes our non-zero arrow v and crushes it to the zero vector. A matrix that can crush a non-zero arrow to nothing must be singular — it collapses space flat, losing a dimension. And the signature of a singular matrix is that its determinant is zero. (The determinant measures how much a matrix scales area/volume; a determinant of 0 means it flattens everything, which is exactly the collapse we need.) That gives us the master key:
This is the characteristic equation. Expanding the determinant produces a polynomial in λ — the characteristic polynomial — whose roots are exactly the eigenvalues. For an n×n matrix it's a degree-n polynomial, so an n×n matrix has n eigenvalues (counting repeats and allowing complex ones).
For a 2×2 matrix the determinant is the down-diagonal product minus the up-diagonal product:
Let's grind a complete example by hand. Take
Step 1 — build A − λI. Subtracting λI means subtracting λ from each diagonal entry, nothing else:
Step 2 — take its determinant using a·d − b·c, where now a = (4−λ), d = (3−λ), b = 1, c = 2:
Step 3 — expand the product, term by term so nothing hides. (4−λ)(3−λ) = 4·3 + 4·(−λ) + (−λ)·3 + (−λ)(−λ) = 12 − 4λ − 3λ + λ² = λ² − 7λ + 12. Then subtract the 2:
Step 4 — set it to zero and solve. The characteristic equation is λ² − 7λ + 10 = 0. We need two numbers that multiply to 10 and add to 7. That's 5 and 2:
The eigenvalues of A are 5 and 2. Done — entirely by hand, every step visible.
The eigenvalue tells you the stretch; to get the direction, plug λ back into (A − λI)·v = 0 and solve. For λ = 5: A − 5I = [[4−5, 1], [2, 3−5]] = [[−1, 1], [2, −2]]. The top row says −1·v₁ + 1·v₂ = 0, i.e. v₂ = v₁. So any multiple of [1, 1] is the eigenvector for λ = 5. (The bottom row, 2v₁ − 2v₂ = 0, says the same thing — it must, because the matrix is singular and the two rows are secretly the same equation.)
Quick verify: A·[1,1] = [4·1 + 1·1, 2·1 + 3·1] = [5, 5] = 5·[1,1]. ✓ The eigenvalue and its eigenvector agree.
Drag the matrix entries. The curve is the characteristic polynomial λ² − (trace)λ + (det). Where it crosses zero (the orange dots) are the eigenvalues. Watch them go complex (curve lifts off the axis) when the discriminant turns negative.
python import numpy as np def eig_2x2(a, b, c, d): # characteristic poly: lam^2 - (trace) lam + (det) = 0 tr = a + d det = a * d - b * c disc = tr * tr - 4 * det # the quadratic discriminant root = disc ** 0.5 # complex automatically if disc < 0 return (tr + root) / 2, (tr - root) / 2 print(eig_2x2(4, 1, 2, 3)) # (5.0, 2.0) -- matches our hand work print(np.linalg.eigvals([[4.,1],[2,3]])) # [5. 2.] -- the library agrees
eigvals does exactly what we did by hand — it builds the characteristic polynomial and finds its roots. The library is not magic; it's our procedure, automated.Chapter 2's machinery — expand the determinant, build the polynomial, solve it — works for any matrix but it's labor. For one enormous family of matrices, you can skip the entire calculation and read the eigenvalues straight off. Those are the triangular matrices, and the shortcut is the single most useful trick in this lesson.
A matrix is upper-triangular when every entry below the main diagonal is zero (the non-zero stuff sits on or above the diagonal, forming a triangle in the upper-right). Lower-triangular is the mirror image, zeros above the diagonal. Here's the punchline:
This isn't a coincidence to memorize; it falls out of two facts. Fact 1: subtracting λI from a triangular matrix keeps it triangular (you only touch the diagonal, and the zeros stay put). Fact 2: the determinant of a triangular matrix is just the product of its diagonal entries — the off-diagonal stuff can't contribute, because every term in the determinant expansion that uses an off-diagonal entry is forced to also pick up one of the structural zeros, killing that term.
Watch it on a 3×3 upper-triangular matrix. Form A − λI:
(The asterisks are whatever was above the diagonal — they don't matter.) By Fact 2, the determinant is the product of the diagonal:
Set it to zero: (a−λ)(b−λ)(c−λ) = 0. A product is zero exactly when one of its factors is zero, so the solutions are λ = a, λ = b, λ = c — the diagonal entries themselves. The characteristic polynomial came pre-factored. That's the whole proof.
Now the matrix this lesson was built around — the one from the AA174A pre-knowledge assessment:
Every entry below the diagonal is zero, so it's upper-triangular. By the shortcut, the eigenvalues are the diagonal entries read top-left to bottom-right:
That's the answer to the assessment question — 5, −2, and 1 — and you can see it in under a second without writing a single line of algebra. To convince yourself it isn't sleight of hand, do it the long way for this matrix: A − λI = [[5−λ, 3, 1], [0, −2−λ, −4], [0, 0, 1−λ]]. Expanding the determinant along the first column (which has a single non-zero entry, 5−λ, since the two below it are zero) gives (5−λ) times the determinant of [[−2−λ, −4], [0, 1−λ]]. That inner 2×2 is itself triangular, so its determinant is (−2−λ)(1−λ). Altogether det = (5−λ)(−2−λ)(1−λ) — the diagonal product, exactly as promised.
Drag the diagonal entries of this 3×3 upper-triangular matrix. The orange highlighted diagonal is, instantly, the list of eigenvalues. The off-diagonal numbers (greyed) never affect them.
python import numpy as np A = np.array([[5., 3, 1], [0, -2, -4], [0, 0, 1]]) # The shortcut: eigenvalues ARE the diagonal of a triangular matrix. print(np.diag(A)) # [ 5. -2. 1.] # The general solver agrees (order may differ -- eigenvalues are a SET). print(sorted(np.linalg.eigvals(A).real)) # [-2.0, 1.0, 5.0]
np.diag returns them in diagonal order (5, −2, 1) while the solver may return them sorted or in any order. That's fine — the eigenvalues of a matrix form an unordered collection. We sorted them only to make the equality obvious to the eye.Solving the characteristic polynomial is fine for 2×2 or 3×3 matrices. But PageRank operates on a matrix with billions of rows — one per web page. Nobody is expanding a billion-degree polynomial. There's a gorgeous, almost lazy alternative that finds the most important eigenvector by doing nothing but multiplying repeatedly. It's called power iteration, and it's the engine inside PageRank.
The recipe is almost insultingly simple. Start with any random vector. Multiply it by A. Normalize it back to length 1 (so it doesn't blow up or vanish). Multiply by A again. Normalize again. Repeat. The vector swings around and then locks onto the eigenvector with the largest eigenvalue — the dominant eigenvector. Watch:
Here is the entire secret, and it's worth savoring. Any starting vector can be written as a blend of the eigenvectors. Suppose A has eigenvectors v₁, v₂ with eigenvalues λ₁, λ₂, and we write our start as a mix:
Now multiply by A. Because each v is an eigenvector, A just scales each piece by its own λ:
Multiply by A again, and each piece picks up another factor of its eigenvalue. After k multiplications:
Now suppose λ₁ is the bigger eigenvalue (say λ₁ = 4, λ₂ = 1). Then λ₁ᵏ = 4ᵏ rockets up while λ₂ᵏ = 1ᵏ stays at 1. After 10 steps the first piece is scaled by 4¹⁰ ≈ 1,000,000 and the second by 1. The v₁ piece utterly drowns out the v₂ piece. Whatever you started with, after enough multiplications the vector points essentially all in the v₁ direction. Normalizing each step just keeps the length sane while this domination plays out.
We can also recover the eigenvalue itself, not just its direction. Once v has locked onto the dominant eigenvector, the Rayleigh quotient reads off the eigenvalue: λ ≈ vᵀ A v (for a unit-length v). It literally asks “by what factor did A stretch v?” and since v is now an eigenvector, that factor is the eigenvalue.
Take A = [[2, 1], [1, 3]] and start at v₀ = [1, 0]. Multiply: w = A·[1,0] = [2·1 + 1·0, 1·1 + 3·0] = [2, 1]. Rayleigh estimate before normalizing v: λ ≈ v₀ᵀ w = [1,0]·[2,1] = 1·2 + 0·1 = 2. Normalize: ‖[2,1]‖ = √(4+1) = √5 ≈ 2.236, so v₁ = [2, 1]÷2.236 = [0.894, 0.447]. Already the vector has tilted away from pure east toward the dominant direction. Repeat a few times and the Rayleigh estimate climbs toward the true dominant eigenvalue, which for this matrix is (5 + √5)÷2 ≈ 3.618.
python import numpy as np def power_iteration(A, steps=25): v = np.array([1., 0.]) # any non-zero start works for _ in range(steps): w = A @ v # multiply lam = v @ w # Rayleigh quotient (v is unit-norm) v = w / np.linalg.norm(w)# normalize back to length 1 return lam, v A = np.array([[2., 1], [1, 3]]) lam, v = power_iteration(A) print(round(lam, 4)) # ~3.618 print(max(np.linalg.eigvals(A).real)) # 3.618... -- exact match
np.linalg.eigvals solves the polynomial and returns all eigenvalues at once; power iteration finds only the dominant one but does so with nothing fancier than matrix–vector products — which is exactly why it scales to billion-page web graphs where polynomial methods are hopeless.You can now find eigenvalues four ways: by definition-checking, by the characteristic polynomial, by the triangular shortcut, and by power iteration. This final chapter is the payoff — why three of the most important systems in engineering are, underneath, just eigenvalue problems. And it's where the showcase simulation lets you watch the dominant eigenvector emerge from a cloud of iterates.
Imagine a system whose state x evolves by repeated multiplication: xₘ₊₁ = A·xₘ. (A spring-mass-damper discretized in time looks exactly like this.) Will the system settle to rest, or shake itself apart? Decompose the state into eigenvectors, and each component just multiplies by its eigenvalue every step — the same exponential race from Chapter 4. So:
This is precisely the story told in the ODEs → State-Space lesson, where the spring-damper's behavior — overdamped crawl, critically-damped snap, underdamped oscillation, or unstable blow-up — is decided entirely by the eigenvalues of its state matrix A. The discriminant b² − 4mk that sorts the four regimes there is nothing but the discriminant of the characteristic polynomial we built in Chapter 2. The regimes are the eigenvalues. A negative real part means decay (stable); a non-zero imaginary part means oscillation; a positive real part means it shakes itself apart.
Given a cloud of data points, Principal Component Analysis asks: along which direction does the data vary the most? Form the covariance matrix of the data; its eigenvectors are the principal directions, and each eigenvalue is the amount of variance captured along its eigenvector. The biggest eigenvalue points along the data's longest axis. Keep the top few eigenvectors and you've compressed the data while throwing away the least information — that's dimensionality reduction in one sentence.
Google's original ranking treats the web as a giant matrix: entry (i, j) is the probability a random surfer hops from page j to page i. The importance score of every page is the dominant eigenvector of that matrix — the steady-state distribution of where a random surfer spends their time. And how do you find the dominant eigenvector of a billion-by-billion matrix? Power iteration, exactly Chapter 4. PageRank is power iteration on the web graph. The whole edifice of early Google search is one eigenvector.
Below is the lesson's centerpiece. A 2×2 matrix A acts on a vector; we repeatedly multiply and normalize, drawing each iterate. You control A. Watch the trail of arrows fan out and then collapse onto the dominant eigenvector — and watch the eigenvalue estimate climb to the true value. Push the off-diagonal coupling and stretch values around; make the two eigenvalues nearly equal and watch convergence slow to a crawl (that's the |λ₂|∕|λ₁| ratio biting).
The teal lines are the true eigenvectors. The fading blue arrows are the iterates v₀, v₁, v₂, … The bright orange arrow is the current estimate. Press Step to advance one multiplication, or Run to animate. Watch the orange arrow swing onto the dominant teal line.
| Idea | Formula / Rule | What it means |
|---|---|---|
| Definition | A·v = λ·v, v ≠ 0 | v is a direction A only stretches; λ is the stretch factor. |
| Find eigenvalues | det(A − λI) = 0 | Roots of the characteristic polynomial. |
| 2×2 checks | sum = trace, product = det | Free sanity check on your roots. |
| Triangular shortcut | λ = diagonal entries | Read them off directly; no algebra. |
| Power iteration | v ← A·v / ‖A·v‖ | Converges to the dominant eigenvector. |
| Eigenvalue from vector | λ ≈ vᵀA·v | Rayleigh quotient (v unit-length). |
| Stability (discrete) | all |λ| < 1 | System decays to rest. |
| Stability (continuous) | all Re(λ) < 0 | Negative real part = decay. |
You've met eigenvalues as stretch factors, learned four ways to find them, and seen them decide stability, drive PCA, and rank the web. The natural next step is to see them in action governing a physical system: the ODEs → State-Space lesson takes a spring-mass-damper, writes it as x′ = A·x, and shows that the eigenvalues of A — their real parts and imaginary parts — are exactly the damping regimes you can feel when you tap a real spring. Everything you proved here about the characteristic polynomial becomes the discriminant that sorts a wobble from a crash.
Chapter 5's showcase let you press Step on a finished animation. Here you write the two lines that ARE power iteration and watch your code swing a unit arrow onto the dominant eigenvector — the same A = [[2, 1], [1, 3]] from Chapter 4, dominant eigenvalue (5 + √5)/2 ≈ 3.618. Press Run (Python boots once, ~5s), then play the animation.
The lesson showed you eigenvalues four ways. This workbook makes you produce them — every exercise asks you to derive, trace, build, design, or debug, never just recall. Work them with a blank sheet and a pencil; the answers check your arithmetic, and every reveal walks the full path. Nothing is a placeholder.
Everything starts with one equation: the matrix only stretches an eigenvector. These exercises make you test that pattern in both directions.
For A = [[3, 0], [8, −1]], the vector v = [0, 1] is claimed to be an eigenvector. Compute A·v and read off the eigenvalue. Enter λ.
Hint: A·[0,1] picks out the second column of A.
Every component scaled by the same −1, so [0,1] is genuinely an eigenvector and its eigenvalue is −1.
A matrix sends the eigenvector v = [2, −2] to A·v = [−6, 6]. Since [−6, 6] is a scalar multiple of [2, −2], what is the eigenvalue?
Check the other component: −3 × (−2) = 6 ✓. The negative eigenvalue means A flips the arrow backwards and triples its length.
Write stretch(a, b, c, d, v1, v2) for A = [[a,b],[c,d]] and v = [v1, v2]. Return the array A·v = [a·v1 + b·v2, c·v1 + d·v2].
javascript function stretch(a, b, c, d, v1, v2) { return [a * v1 + b * v2, c * v1 + d * v2]; }
To find eigenvalues from scratch you expand a determinant into a polynomial and solve it. These drill the full 2×2 grind, plus the trace/determinant sanity checks.
For A = [[4,1],[2,3]], the characteristic polynomial is λ² − (trace)λ + (det). What is its constant term (the determinant of A)?
Hint: det = a·d − b·c.
The constant term of the 2×2 characteristic polynomial is always exactly det A. The coefficient of λ (with its minus sign) is the trace.
Solve λ² − 7λ + 10 = 0 (the polynomial of A = [[4,1],[2,3]]). Enter the larger root.
Hint: two numbers multiplying to 10 and adding to 7.
Check: 5 + 2 = 7 = trace ✓, 5 × 2 = 10 = det ✓. Both shortcuts confirm the roots.
A 2×2 matrix has trace 0 and determinant −9. Its eigenvalues sum to 0 and multiply to −9. Enter the positive eigenvalue.
Trace and determinant alone pin down the eigenvalues of a 2×2 — you never even needed the matrix entries.
For A = [[0,−1],[1,0]] (a 90° rotation), trace = 0 and det = 1, so the polynomial is λ² + 1 = 0. Compute the discriminant tr² − 4det.
A negative discriminant means complex eigenvalues — no real direction is preserved, which makes sense for a pure rotation.
Negative discriminant → complex eigenvalues ±i. A 90° rotation has NO real eigenvector — every real arrow gets turned, which is exactly what the imaginary eigenvalues encode.
For A = [[4,1],[2,3]] and the eigenvalue λ = 2, the equation (A − 2I)v = 0 has top row (4−2)v₁ + 1·v₂ = 0, i.e. 2v₁ + v₂ = 0. If v₁ = 1, what is v₂?
Verify: A·[1,−2] = [4−2, 2−6] = [2, −4] = 2·[1,−2] ✓. Plugging λ back into (A−λI)v=0 always recovers the direction.
Write eig2(a, b, c, d) returning the two real eigenvalues of [[a,b],[c,d]] as [larger, smaller] using the quadratic formula on λ² − (a+d)λ + (ad−bc).
javascript function eig2(a, b, c, d) { var tr = a + d, det = a * d - b * c; var root = Math.sqrt(tr * tr - 4 * det); return [(tr + root) / 2, (tr - root) / 2]; }
A student expands the characteristic polynomial of A = [[4,1],[2,3]]. Exactly one line has a sign error. Click it.
A - λI = [[4-λ, 1], [2, 3-λ]] det = (4-λ)(3-λ) - (1)(2) expand: (4-λ)(3-λ) = 12 - 7λ + λ² det = 12 - 7λ + λ² + 2 # subtract the off-diagonal product char. poly: λ² - 7λ + 14 = 0 (this gives the wrong roots)
Put the steps of finding eigenvalues via the characteristic polynomial in order.
When a matrix is triangular, the eigenvalues are its diagonal. These exercises drill the shortcut and the assessment matrix it was built for.
The trace (sum of the diagonal) always equals the sum of the eigenvalues. For [[5,3,1],[0,−2,−4],[0,0,1]], what is that sum?
The trace equals the sum of eigenvalues for ANY square matrix, triangular or not — here it's also just the diagonal sum.
The determinant always equals the product of the eigenvalues. For the assessment matrix, what is 5 × (−2) × 1?
det = product of eigenvalues. For a triangular matrix the determinant is also just the diagonal product, so both views agree: −10.
A diagonal matrix is triangular both ways. For diag(7, 0, −3), enter the eigenvalue that equals zero's neighbor on the diagonal — specifically, the largest eigenvalue.
A zero on the diagonal is a perfectly valid eigenvalue — it means the matrix flattens that direction to the origin.
Write triEig(d1, d2, d3) that returns the eigenvalues of a 3×3 triangular matrix whose diagonal is [d1, d2, d3]. Just return the diagonal as an array.
javascript function triEig(d1, d2, d3) { return [d1, d2, d3]; }
A student finds eigenvalues of the upper-triangular [[5,3,1],[0,−2,−4],[0,0,1]]. Exactly one line is wrong. Click it.
matrix is upper-triangular (zeros below diagonal) shortcut: eigenvalues = the diagonal entries diagonal = 5, -2, 1 eigenvalues = 5, 3, 1 # read the top ROW instead of the diagonal check: sum should equal trace 5 + (-2) + 1 = 4 but 5 + 3 + 1 = 9 ≠ 4, so something is wrong
Repeated multiply-and-normalize finds the biggest eigenvalue without any polynomial. These exercises run the loop by hand and reason about its convergence.
Power iteration on A = [[2,1],[1,3]] starts at v = [1, 0]. Compute w = A·v and enter its top component.
w = [2, 1]. The vector has already tilted off the x-axis toward the dominant direction.
With v = [1, 0] (unit-length) and w = A·v = [2, 1], the eigenvalue estimate is λ ≈ vᵀw = v₁w₁ + v₂w₂. Compute it.
First estimate is 2; the true dominant eigenvalue of this matrix is about 3.618, so iterating will climb the estimate upward.
After w = [2, 1], the norm is ‖w‖ = √(2² + 1²) = √5 ≈ 2.236. Compute the top component of the normalized vector v = w/‖w‖. (Round to 3 decimals.)
Normalizing keeps the length at 1 so the vector neither explodes nor vanishes over many steps — only its direction matters.
Write powerStep(a, b, c, d, v1, v2) for A = [[a,b],[c,d]] and unit vector v = [v1, v2]. Multiply w = A·v, then return the normalized [w1/norm, w2/norm] where norm = √(w1² + w2²).
javascript function powerStep(a, b, c, d, v1, v2) { var w1 = a * v1 + b * v2, w2 = c * v1 + d * v2; var norm = Math.sqrt(w1 * w1 + w2 * w2); return [w1 / norm, w2 / norm]; }
Put one iteration of power iteration in the correct order.
A student writes a power-iteration loop. Exactly one line breaks it. Click it.
v = [1, 0] # start for step in range(25): w = A @ v # multiply lam = v @ w # Rayleigh estimate v = w # forgot to normalize! v grows without bound return lam, v
Eigenvalues decide whether a dynamical system settles or explodes. These exercises connect eigenvalues to stability and ask you to design matrices with target eigenvalues.
You want a 2×2 matrix with eigenvalues 3 and −5. The easiest construction is diagonal. Enter the trace (which must equal 3 + (−5)) of your matrix.
To build a matrix with target eigenvalues, the trivial answer is to put them on the diagonal. The trace then equals their sum, −2.
You want a (non-diagonal) 2×2 matrix with eigenvalues 4 and 1. Any such matrix must have determinant equal to their product. What determinant must you target?
Fix trace = 5 (= sum) and det = 4 (= product) and ANY 2×2 with those two invariants has eigenvalues 4 and 1, diagonal or not.
Write isStable(lam1, lam2) returning true if BOTH eigenvalues satisfy |λ| < 1 (discrete-time stable), else false.
javascript function isStable(lam1, lam2) { return Math.abs(lam1) < 1 && Math.abs(lam2) < 1; }
A student writes a continuous-time stability check (x′ = A·x is stable iff every eigenvalue has negative real part). Exactly one line has the test backwards. Click it.
eigs = eigenvalues(A) # may be complex stable = True for lam in eigs: if lam.real > 0: # POSITIVE real part means stable stable = False return stable # comment is backward: positive real = UNSTABLE