Section 1
Decomposing a matrix
As with prime factors, shows structure the digits hide. A decomposition does the same for a matrix.
An eigendecomposition splits a matrix into eigenvectors and eigenvalues. (Added here, not from the book: German eigen means “own”.)
the matrix , , eigenvectors , eigenvalues the quadratic expression , , plain vectors
How to use this pageClick any colored symbol, in an equation or in a sentence, and it explains itself. Then drag things: every section has something to grab.
Picture as a machine. Is there an input that comes out pointing the same way? Drag the black dot and hunt for it.
Hunt for directions that survive
a direction that survives
Challenge +8 XPFind a direction where the violet arrow lies exactly along the black one. A teal ring appears when you have it.
On Symmetric the curve touches zero at 45° and 135°. At 45° the violet arrow is 3 times longer and points the same way. At 135° it keeps its length. Those two lines are the matrix’s own directions.
Skewed has two such lines, but not at right angles. Shear has only one. Rotation has none, because it turns every arrow. The rest of this page makes that precise.
Section 2
Eigenvectors and eigenvalues
The direction you found has a name. An eigenvector of a square matrix is a non-zero vector that only rescales:
Click any coloured symbol to see what it means.
The number is its eigenvalue, the stretch factor along that direction. Above 1 it stretches, between 0 and 1 it shrinks, below 0 it flips the arrow, and 0 squashes it onto the origin. Think of pulling a rubber sheet: the lines along the pull stay lines.
The word “non-zero” matters. The zero vector satisfies the equation for every and tells you nothing.
Going deeper: left eigenvectors
The book also mentions a left eigenvector, defined by multiplying from the left: . The usual object, and the only one used here, is the right eigenvector of Equation 2.39.
Now drag the tip of the black arrow . The violet arrow is . When do they line up?
Drag until lines up
Challenge +8 XPOn the Flipper tab, drag until points exactly the opposite way from . Two teal rings appear.
Slide the tip along a line where the arrows match. The arrow gets longer or shorter, but the factor stays the same. That is the book’s rescaling remark: if is an eigenvector, so is for any , with the same eigenvalue.
Since every multiple works, the book looks only for unit eigenvectors. Length is free. The direction is what counts.
Finding eigenvalues
The book states Equation 2.39 and moves on. To compute eigenvalues you need one more step (added here, not printed in the book). Rewrite the equation as . A non-zero can solve it only if squashes some direction to zero, so that matrix is singular and has determinant 0:
Click any coloured symbol to see what it means.
For a 2 by 2 matrix this is a parabola in . Its coefficients are the trace , the sum of the diagonal entries, and the determinant , the number that is zero exactly when the matrix squashes a direction:
Click any coloured symbol to see what it means.
The plotted curve is , and the eigenvalues are its roots. Drag the dot along it, or reshape the parabola with the matrix entries, and watch where it hits zero.
Eigenvalues as roots of a parabola
Challenge +8 XPDrag the dot onto a root of the parabola, where it touches zero. Use the slider for fine steps.
Challenge +8 XPChange the four entries so that the parabola touches zero from above: one repeated eigenvalue. (Try making the matrix 2 times the identity, or look for another way.)
Two crossings give two real eigenvalues. A parabola that only touches zero gives one repeated eigenvalue. A parabola floating above zero has no real root, so the eigenvalues are complex (Section 5). Software finds the roots of bigger matrices with iterative methods and never expands the polynomial.
Section 3
The eigendecomposition
Suppose an by matrix has linearly independent eigenvectors , meaning none is a mix of the others. Put them side by side as the columns of , and the eigenvalues into a vector . The eigendecomposition is
Click any coloured symbol to see what it means.
Read it from the right, like a recipe. Converting cups to grams, doubling the flour, then converting back is one way to scale a recipe. The three factors work the same way.
- converts the arrow into eigen-coordinates, measured along the eigenvectors.
- scales each coordinate by its own eigenvalue. This is the cheap diagonal operation of Section 2.6.
- converts back to the original axes.
A complicated stretch is a plain scaling seen from a tilted viewpoint. Drag the ring to put a point of your own through the three moves, then slide or press Play.
Apply A in three moves
startcurrent frame and your point’s patheigenvector 1eigenvector 2
In the first third the eigenvector arrows swing onto the axes. In the second third only the axes are stretched. In the last third everything swings back. The arrows end at , which is , as Equation 2.39 says.
Going deeper: why the formula holds
Added here, not printed in the book. The product acts on each column of separately. Each column is an eigenvector, so column of the product is . Scaling column of by gives the same thing, and that is what a diagonal matrix on the right does:
Independent eigenvectors make invertible. Multiply both sides on the right by and Equation 2.40 appears. With dependent eigenvectors there is no inverse, which is what fails for the shear in Section 5.
Build one yourself
Now run it backwards. Choose the eigenvector arrows and the eigenvalues, and the machine builds . Push the two arrows onto one line and see what breaks.
Build a matrix from its parts
(drag its tip) (drag its tip)unit circle after
Challenge +8 XPBuild a matrix with eigenvalues 3 and 1 that is not symmetric: the readout must say its two off-diagonal entries differ.
Symmetric matrices are the ones whose eigenvector arrows are at right angles (Section 4). Any other angle gives a matrix that is not symmetric but is still fully described by its arrows and eigenvalues.
Why the form is useful
The book compares the decomposition with prime factors: it shows properties the raw entries hide. One example, added here, is repeated multiplication. In the middle cancels to the identity, so only the eigenvalues get squared. In general
Click any coloured symbol to see what it means.
Powers through the decomposition
Uses the matrix you built above.
The first row multiplies by itself times. The second raises two numbers to the power and sandwiches them between and . The two agree up to rounding, and the second needs only powers of numbers.
Section 4
Real symmetric matrices
Some matrices cannot be decomposed, and some need complex numbers. Section 5 shows both. The book needs only one friendly class, real symmetric matrices (those with , from Section 2.6), and for them the news is good. Everything stays real:
Click any coloured symbol to see what it means.
Here is an orthogonal matrix whose columns are eigenvectors of , and is a diagonal matrix with eigenvalue for column of . This is Equation 2.40 with a bonus: the eigenvectors are perpendicular unit arrows, so and the expensive inverse disappears.
Figure 2.3, rebuilt
Perpendicular axes mean scales space by along . The left plot holds every unit vector , a circle. The right plot holds every point . Grab the arrow tips and pull.
Figure 2.3: a circle becomes an ellipse
and and circle (left) and its image (right)
Challenge +8 XPTurn the ellipse so its long axis, , points at 60°, with semi-axes = 3 and = 1.
The ellipse always has its axes along the eigenvectors, stretched by the eigenvalues. A negative also mirrors the ellipse. Equal eigenvalues give a circle at any angle, because when every direction is stretched equally, every direction is an eigenvector.
Beyond two dimensions
Pictures stop at two dimensions. The decomposition does not. Type any symmetric 3 by 3 matrix and the lab finds and with the Jacobi method (added here: the book does not describe it), which rotates away the off-diagonal entries one at a time. It then multiplies the factors back and checks that Equation 2.41 holds.
How the Jacobi routine was checked
This check ran outside the page, not in the browser. The routine matches NumPy eigvalsh on several hundred random symmetric matrices of sizes 1 to 6, with a worst deviation below 2e-14. Added here, not from the book.
Eigendecomposition of a symmetric 3 by 3 matrix
Challenge +8 XPGuided step: type 4, 1 and 2 on the diagonal and 0 everywhere else. Before you read the readout, say which eigenvectors you expect. The eigenvalues should come out as 4, 2 and 1.
Eigenvalues come out sorted, largest first. The rebuild error is printed as below , the level of rounding. That is Equation 2.41’s guarantee for any symmetric input.
Section 5
Uniqueness and failure
When the decomposition is not unique
Every real symmetric matrix has an eigendecomposition, but it may not be unique. If eigenvalues repeat, any orthogonal vectors in their span are eigenvectors too, so a different works. With the entries of sorted in descending order, the decomposition is unique only if all eigenvalues are distinct.
Turn your guess for (drag on the plane) until the dashed ellipse built from covers the solid ellipse, .
Guess the eigenvectors
target your guessyour second axis
Challenge +8 XPIn the Different eigenvalues tab, turn your guess until the reconstruction error drops below 0.06.
With distinct eigenvalues the error is zero at one angle only. With equal eigenvalues the target is , every basis reproduces it, and the error is zero everywhere. One more remark, added here: each eigenvector can be negated without changing the product, so “unique” means unique up to signs.
When the decomposition fails
The book says it plainly: not every matrix can be decomposed this way. Sometimes the decomposition needs complex numbers. Sometimes has fewer than independent eigenvectors, and then has no inverse. Try to break it.
Three matrices, three fates
unit circleits imagereal eigenvector lines
Challenge +8 XPOn the Rotation tab, find the turn (other than 0) at which real eigenvectors come back.
A rotation turns every vector, so no real direction survives. The eigenvalues are the complex pair . The decomposition exists, but over the complex numbers. A shear has the repeated eigenvalue 1 and one eigenvector line, so cannot be inverted. A symmetric matrix always has two real perpendicular lines.
Section 6
What the eigenvalues reveal
The decomposition hands you several facts for free. First, a matrix is singular if and only if one of its eigenvalues is zero. A zero eigenvalue means for some non-zero : a whole line is squashed onto the origin, and a squashed line cannot be restored.
Squash a direction
originalafter Adirections squashed to zero
Challenge +8 XPMake the matrix singular: flatten the F onto a line.
With one eigenvalue at 0, different inputs share one output, and no inverse can tell them apart.
Optimizing a quadratic expression
The decomposition also solves a classic optimization problem. For a real symmetric , consider
Click any coloured symbol to see what it means.
The book states three results. When is a unit eigenvector, equals the matching eigenvalue. The maximum of on the unit circle is the largest eigenvalue, and the minimum is the smallest. The reason, added here: write for the coordinates of along the eigenvectors. Then
Click any coloured symbol to see what it means.
Since keeps lengths, the numbers are non-negative and add to 1. So is a weighted average of the eigenvalues. An average cannot beat the biggest value or fall under the smallest, and it reaches them when all the weight sits on one eigenvector.
Drag around the circle. The ring is teal where is positive and orange where it is negative. The lower plot unrolls it.
The quadratic form around the circle
around the circlelargest eigenvaluesmallest eigenvalue
Challenge +8 XPDrag to the spot where is as large as it can be, then to the spot where it is as small as it can be. Both need to be within 0.05 of an eigenvalue.
The wave rises to the largest eigenvalue and sinks to the smallest. Peaks sit where lies along an eigenvector. Turn the eigenvectors and the wave slides sideways without changing height. Change the eigenvalues and the peak and trough follow them.
Section 7
Definiteness
The signs of the eigenvalues give symmetric matrices a vocabulary. All eigenvalues positive: positive definite. All positive or zero: positive semidefinite. All negative: negative definite. All negative or zero: negative semidefinite.
These names promise something about . A positive semidefinite matrix guarantees
Click any coloured symbol to see what it means.
A positive definite matrix adds that only the zero vector makes the expression vanish:
Click any coloured symbol to see what it means.
Both follow from the weighted average. If every eigenvalue is at least 0, so is any average of them. If every eigenvalue is above 0, the average hits 0 only when every weight is 0, which forces .
Before you see the picture, commit to a guess. Each round shows the eigenvalues of a symmetric matrix. Say what does, then the map is revealed.
Predict the shape
positivenegativeeigenvector lines
Challenge +8 XPGet four predictions right in a row.
Now play freely. The map shows the sign of over the whole plane.
Sign of over the plane
positivenegativeeigenvector lines
Challenge +8 XPBuild a matrix that is positive semidefinite but not positive definite: one eigenvalue exactly 0, the other positive.
Two positive eigenvalues give a bowl, teal everywhere except the origin. Send to 0 and a whole line of vectors makes the expression vanish. Opposite signs split the plane into teal and orange: the matrix is indefinite (a name added here, not defined in the book), and none of the four names fits. Both negative flips every sign.
What to take away
- An eigenvector satisfies : the matrix only rescales it, by the eigenvalue.
- With independent eigenvectors, .
- A real symmetric matrix factors as with orthogonal and real diagonal . It scales space by along .
- The decomposition is unique, with eigenvalues sorted, only if all eigenvalues differ. Some matrices have only complex eigenvalues, and some lack enough eigenvectors.
- A matrix is singular exactly when an eigenvalue is 0. On unit vectors lies between the smallest and largest eigenvalue.
- Positive semidefinite means for all . Positive definite adds that the value is 0 only at .
Final quizCheck yourself
Questions that mix the whole module. Each one is scored, and the score feeds your mastery of this module.
Source: Ian Goodfellow, Yoshua Bengio and Aaron Courville, Deep Learning, MIT Press, 2016, Section 2.7 (pages 42–44), free to read at deeplearningbook.org. Where the book prints equation numbers, the numbers here follow the book. The order of ideas follows the book. The explanations and all demos were written for this page.