Flow Lab

Syllabus / Module 1: Linear Algebra, Reloaded

Lesson 1.6

Change of Basis & Diagonalization

Looking at a transformation in its eigenvector basis turns it into simple scaling: A = PDP⁻¹, powers of matrices, and symmetric matrices.

Written byClaude Opus

🌊
Why this matters for simulation: Normal modes of vibrating structures and Fourier modes of a grid are both eigenbases that decouple a hard problem into many easy ones.

By the end of this lesson you can…

  • Convert a vector's coordinates between the standard basis and any other basis using P and P⁻¹.
  • Compute the matrix of a transformation in a new basis, B = P⁻¹AP, and explain why similar matrices share eigenvalues, trace and determinant.
  • Diagonalize a 2×2 or 3×3 matrix as A = PDP⁻¹ and use it to compute Aⁿ in closed form.
  • Decide whether a matrix is diagonalizable, and recognize defective matrices like the shear.
  • Apply the spectral theorem to a symmetric matrix to find the principal axes of an ellipse.
  • Decouple a coupled linear recurrence or ODE system into independent scalar problems, and connect this to normal modes and Fourier modes.
On this page
·
  1. Coordinates in a different basis
  2. Change-of-basis matrices (both directions)
  3. The same transformation in a different language: similarity
  4. What similar matrices share
  5. Diagonalization: A = PDP⁻¹
  6. Worked example: diagonalize a matrix by hand
  7. Computing powers: Aⁿ = PDⁿP⁻¹
  8. Worked example: Fibonacci in closed form
  9. When diagonalization fails
  10. Symmetric matrices and the spectral theorem
  11. Worked example: principal axes of an ellipse
  12. Decoupling coupled systems
  13. Worked example: two masses, three springs
  14. Diagonalization in code
  15. Key Takeaways

Suppose you are simulating two masses connected by springs, or a population split between a city and its suburbs, or the temperature at a thousand points along a rod. In every case the equations are coupled: what happens to one variable depends on all the others, so you can’t solve for any of them alone. In 1.5 Eigenvectors & Eigenvalues you found the special directions a matrix only stretches. This lesson cashes those eigenvectors in. If you describe the system in the eigenvector basis, the coupling vanishes and the matrix becomes diagonal: pure scaling, one independent number per direction. That single idea gives closed-form matrix powers, the solution of linear ODE systems, normal modes of vibration, and the spectral methods that the fastest fluid solvers use.

▶ Video The same transformation in two languages: standard grid vs eigen-grid, and A = PDP⁻¹captions only
Transcript
  1. Last time we found eigenvectors: the special directions a matrix only stretches. Today we cash them in.
  2. Here is a matrix A acting on the ordinary grid. Watch the grid lines: they tilt, they stretch, they shear. Every new coordinate is a mix of both old ones.
  3. In the standard basis this looks messy. Four numbers, all tangled together. But the transformation itself is not messy. We are just describing it in the wrong language.
  4. This matrix has two eigenvectors. Along v one, two one, it stretches by two. Along v two, negative one one, it shrinks by one half.
  5. So let's build a new grid out of these two directions: lines parallel to v one and lines parallel to v two. It's a skewed grid, just like the ones from lesson one.
  6. Now apply the same matrix. Look: every grid line stays parallel to itself. The grid simply stretches by two in one direction and squashes by half in the other.
  7. Pure scaling along the grid lines. In this basis, the matrix is diagonal: two on the diagonal, one half, and zeros everywhere else.
  8. Take the vector x equals one, two. In standard coordinates, that's one step right and two steps up.
  9. In the eigenbasis it's one step along v one, then one step along v two. Its eigen coordinates are one, one.
  10. Put the eigenvectors in the columns of a matrix P. Then P turns eigen coordinates into standard coordinates, and P inverse goes the other way.
  11. That gives the big factorization: A equals P D P inverse. Read it from right to left, because that's the order the matrices hit a vector.
  12. Step one, P inverse: translate into eigen coordinates. The skewed grid straightens into an ordinary square grid, and x lands on one, one.
  13. Step two, D: scale. Stretch the first axis by two, squash the second by one half. Nothing else happens, the axes don't mix.
  14. Step three, P: translate back to standard coordinates. And x lands exactly where A sends it, three and a half, two and a half.
  15. Same transformation, different language. A and D are called similar matrices, and they share everything intrinsic: eigenvalues, determinant, and trace.
  16. Now the payoff. Multiply A by itself n times, and all the inner P inverse P pairs cancel. A to the n is P, D to the n, P inverse, and powers of a diagonal matrix are trivial.
  17. Watch a point iterate. In eigen coordinates, the first coordinate doubles every step and the second halves.
  18. So the iterates swing over and hug the line of v one. Whichever eigenvalue is biggest in size wins in the long run. That's the dominant eigenvalue, and it predicts the long term shape of any linear recurrence.
  19. Does this always work? No. Here is a shear. Its only eigenvalue is one, repeated.
  20. Apply it, and every arrow gets knocked off its line except the horizontal one. One eigenvector direction is not enough to build a basis, so the shear cannot be diagonalized. We call it defective.
  21. The best case is a symmetric matrix, one that equals its own transpose. Take two one, one two, and send the unit circle through it.
  22. The circle becomes an ellipse, and its axes are exactly the eigenvectors, at right angles to each other, stretched by three and by one.
  23. That's the spectral theorem: a real symmetric matrix always has real eigenvalues and a perpendicular set of eigenvectors. Stiffness matrices and diffusion operators are symmetric, so physics hands us this case all the time.
  24. Here is why we care in differential equations. Two masses joined by three springs. Each mass's acceleration depends on both positions: the equations are coupled.
  25. Change to the eigenvector basis of the stiffness matrix. In the first mode the masses swing together; in the second they swing in opposition, faster.
  26. Each mode obeys its own simple oscillator equation, completely independent of the other. One hard coupled problem became two easy scalar ones.
  27. The same trick powers fluid solvers. On a periodic grid, the sine and cosine waves are eigenvectors of the discrete Laplacian, and the fast Fourier transform is the change of basis.
  28. So diffusion decouples: each mode just decays at its own rate, wiggly modes fastest. That's the heart of spectral methods, which we'll build much later in the course.
  29. To recap: find the eigenvectors, change into their basis, and the matrix becomes pure scaling. Powers, recurrences and coupled systems all fall apart into independent pieces.
  30. Next time: what happens when the eigenvalues aren't even real, and the matrix starts to rotate.

Coordinates in a different basis

Recall from 1.1 Vectors, Linear Combinations & Span that the components of a vector are its coefficients in a basis. Writing x⃗=(1,2)\vec x = (1, 2) really means x⃗=1 ı^+2 ȷ^\vec x = 1\,\hat\imath + 2\,\hat\jmath. Nothing forces us to use ı^\hat\imath and ȷ^\hat\jmath. Any two independent vectors in the plane form a basis, and each basis gives the same arrow different numbers.

Take the skewed basis B={b⃗1,b⃗2}\mathcal B = \{\vec b_1, \vec b_2\} with b⃗1=(2,1)\vec b_1 = (2, 1) and b⃗2=(−1,1)\vec b_2 = (-1, 1). You met this basis in lesson 1.1’s problem “Coordinates in a skewed basis”, where you found that (1,5)=2b⃗1+3b⃗2(1, 5) = 2\vec b_1 + 3\vec b_2. We write

[x⃗]B=[c1c2]meansx⃗=c1b⃗1+c2b⃗2.[\vec x]_{\mathcal B} = \begin{bmatrix} c_1 \\ c_2 \end{bmatrix} \quad\text{means}\quad \vec x = c_1 \vec b_1 + c_2 \vec b_2 .

So [(1,5)]B=(2,3)[(1,5)]_{\mathcal B} = (2, 3). Geometrically, the basis vectors draw a skewed grid, and [x⃗]B[\vec x]_{\mathcal B} gives the grid address of the point x⃗\vec x.

Change-of-basis matrices (both directions)

Stack the new basis vectors as the columns of a matrix:

P=[∣∣b⃗1b⃗2∣∣]=[2−111].P = \begin{bmatrix} | & | \\ \vec b_1 & \vec b_2 \\ | & | \end{bmatrix} = \begin{bmatrix} 2 & -1 \\ 1 & 1 \end{bmatrix}.

Recall from 1.2 Matrices as Transformations that multiplying a matrix by a vector forms a combination of its columns. So

P[c1c2]=c1b⃗1+c2b⃗2=x⃗.P\begin{bmatrix} c_1 \\ c_2 \end{bmatrix} = c_1 \vec b_1 + c_2 \vec b_2 = \vec x .

That gives us both directions:

  x⃗=P [x⃗]B[x⃗]B=P−1x⃗  \boxed{\;\vec x = P\,[\vec x]_{\mathcal B}\qquad\qquad [\vec x]_{\mathcal B} = P^{-1}\vec x\;}
  • PP converts from B\mathcal B-coordinates to standard coordinates. It’s the easy direction: just form the combination.
  • P−1P^{-1} converts from standard coordinates to B\mathcal B-coordinates. It’s the hard direction, because it means solving a linear system. P−1P^{-1} exists because the columns are independent (a basis), so det⁡P≠0\det P \neq 0.

For our basis, det⁡P=2⋅1−(−1)⋅1=3\det P = 2\cdot 1 - (-1)\cdot 1 = 3, and the 2×2 inverse formula (swap the diagonal, negate the off-diagonal, divide by the determinant) gives

P−1=13[11−12],P−1[15]=13[69]=[23].  ✓P^{-1} = \frac13\begin{bmatrix} 1 & 1 \\ -1 & 2 \end{bmatrix}, \qquad P^{-1}\begin{bmatrix} 1 \\ 5 \end{bmatrix} = \frac13\begin{bmatrix} 6 \\ 9 \end{bmatrix} = \begin{bmatrix} 2 \\ 3 \end{bmatrix}. \;✓
✅ Concept check

The columns of $P$ are a basis $\mathcal B$. You know a vector's standard coordinates $\vec x$ and want its $\mathcal B$-coordinates. What do you compute?

The same transformation in a different language: similarity

Now take the transformation from the video,

A=[1.510.51].A = \begin{bmatrix} 1.5 & 1 \\ 0.5 & 1 \end{bmatrix}.

In the standard grid it tilts, stretches and shears every grid line, and each output coordinate mixes both inputs. What does the same transformation look like if we describe everything in B\mathcal B-coordinates?

Suppose you’re handed a vector in B\mathcal B-coordinates, [x⃗]B[\vec x]_{\mathcal B}, and want [Ax⃗]B[A\vec x]_{\mathcal B}. You only know how AA acts on standard coordinates, so take a round trip:

  1. convert to standard coordinates: x⃗=P[x⃗]B\vec x = P[\vec x]_{\mathcal B};
  2. apply the transformation: Ax⃗=AP[x⃗]BA\vec x = AP[\vec x]_{\mathcal B};
  3. convert back: [Ax⃗]B=P−1AP [x⃗]B[A\vec x]_{\mathcal B} = P^{-1}AP\,[\vec x]_{\mathcal B}.

So the matrix of the transformation in the basis B\mathcal B is

  [A]B=P−1AP  \boxed{\;[A]_{\mathcal B} = P^{-1} A P\;}

Two matrices related by B=P−1APB = P^{-1}AP for some invertible PP are called similar. They are the same linear transformation written in two coordinate systems. Here’s the surprise for our basis. Compute APAP column by column:

Ab⃗1=[1.5⋅2+10.5⋅2+1]=[42]=2 b⃗1,Ab⃗2=[−1.5+1−0.5+1]=[−0.50.5]=12 b⃗2.A\vec b_1 = \begin{bmatrix} 1.5\cdot 2 + 1 \\ 0.5\cdot 2 + 1 \end{bmatrix} = \begin{bmatrix} 4 \\ 2 \end{bmatrix} = 2\,\vec b_1, \qquad A\vec b_2 = \begin{bmatrix} -1.5 + 1 \\ -0.5 + 1 \end{bmatrix} = \begin{bmatrix} -0.5 \\ 0.5 \end{bmatrix} = \tfrac12\,\vec b_2 .

The basis vectors are eigenvectors of AA, so

P−1AP=[20012].P^{-1}AP = \begin{bmatrix} 2 & 0 \\ 0 & \tfrac12 \end{bmatrix}.

In the eigen-grid, the transformation just stretches one family of grid lines by 2 and squashes the other by ½. The first B\mathcal B-coordinate doubles and the second halves, and they never interact. All the “messiness” of AA came from describing it in the wrong basis.

Not every basis is this kind. With the basis (1,1),(0,1)(1,1), (0,1), i.e. Q=[1011]Q = \begin{bmatrix} 1 & 0 \\ 1 & 1\end{bmatrix}, you get Q−1AQ=[2.51−10]Q^{-1}AQ = \begin{bmatrix} 2.5 & 1 \\ -1 & 0 \end{bmatrix}, which is still a mess. Only the eigenbasis diagonalizes.

What similar matrices share

Because similar matrices describe the same transformation, anything with a coordinate-free meaning must agree between them:

  • Eigenvalues. The characteristic polynomials are identical: det⁡(P−1AP−λI)=det⁡(P−1(A−λI)P)=det⁡(P−1)det⁡(A−λI)det⁡(P)=det⁡(A−λI).\det(P^{-1}AP - \lambda I) = \det\big(P^{-1}(A - \lambda I)P\big) = \det(P^{-1})\det(A-\lambda I)\det(P) = \det(A - \lambda I). We used λI=P−1(λI)P\lambda I = P^{-1}(\lambda I)P and det⁡(P−1)det⁡(P)=1\det(P^{-1})\det(P) = 1 (1.4 Determinants as Volume Scaling).
  • Determinant (the area-scaling factor) and trace (the sum of the eigenvalues) follow immediately. Check: det⁡A=1.5−0.5=1=2⋅12\det A = 1.5 - 0.5 = 1 = 2\cdot\tfrac12, and tr⁡A=2.5=2+12\operatorname{tr}A = 2.5 = 2 + \tfrac12. The messy Q−1AQQ^{-1}AQ above also has trace 2.52.5 and determinant 0+1=10 + 1 = 1.
  • Eigenvectors are not shared as lists of numbers, because they are the same arrows written in different coordinates. If Av⃗=λv⃗A\vec v = \lambda\vec v, then B(P−1v⃗)=P−1APP−1v⃗=λ(P−1v⃗)B(P^{-1}\vec v) = P^{-1}AP P^{-1}\vec v = \lambda (P^{-1}\vec v).
✅ Concept check

$A$ is a 2×2 matrix with eigenvalues 2 and 5, and $B = P^{-1}AP$ for some invertible $P$. What is the trace of $B$?

Diagonalization: A = PDP⁻¹

Turn the similarity around. If P−1AP=DP^{-1}AP = D is diagonal, multiply by PP on the left and P−1P^{-1} on the right:

Why it works: AP=[Av⃗1⋯Av⃗n]=[λ1v⃗1⋯λnv⃗n]=PDAP = \begin{bmatrix} A\vec v_1 & \cdots & A\vec v_n\end{bmatrix} = \begin{bmatrix} \lambda_1\vec v_1 & \cdots & \lambda_n\vec v_n\end{bmatrix} = PD. Multiplying a matrix on the right by a diagonal matrix scales its columns. Since the columns are independent, PP is invertible, and A=PDP−1A = PDP^{-1}.

Read it right to left. The rightmost matrix hits x⃗\vec x first:

Ax⃗=P⏟3. back to standard  D⏟2. scale each axis  P−1x⃗⏟1. into eigen-coordinatesA\vec x = \underbrace{P}_{\text{3. back to standard}}\;\underbrace{D}_{\text{2. scale each axis}}\;\underbrace{P^{-1}\vec x}_{\text{1. into eigen-coordinates}}

Translate into eigen-coordinates, scale each coordinate by its own λ\lambda, and translate back. The video animates exactly these three steps for x⃗=(1,2)\vec x = (1, 2). Its eigen-coordinates are (1,1)(1, 1), DD sends those to (2,12)(2, \tfrac12), and PP sends that to 2b⃗1+12b⃗2=(3.5,2.5)2\vec b_1 + \tfrac12\vec b_2 = (3.5, 2.5), which matches Ax⃗A\vec x computed directly.

Worked example: diagonalize a matrix by hand

Diagonalize A=[4123]A = \begin{bmatrix} 4 & 1 \\ 2 & 3 \end{bmatrix}.

Step 1: eigenvalues. det⁡(A−λI)=(4−λ)(3−λ)−2=λ2−7λ+10=(λ−5)(λ−2)\det(A - \lambda I) = (4-\lambda)(3-\lambda) - 2 = \lambda^2 - 7\lambda + 10 = (\lambda - 5)(\lambda - 2). So λ1=5\lambda_1 = 5 and λ2=2\lambda_2 = 2. As a check, the trace is 7=5+27 = 5 + 2 and the determinant is 10=5⋅210 = 5\cdot 2.

Step 2: eigenvectors. These come from the kernels of A−λIA - \lambda I:

A−5I=[−112−2]⇒v⃗1=[11],A−2I=[2121]⇒v⃗2=[1−2].A - 5I = \begin{bmatrix} -1 & 1 \\ 2 & -2 \end{bmatrix} \Rightarrow \vec v_1 = \begin{bmatrix} 1 \\ 1 \end{bmatrix}, \qquad A - 2I = \begin{bmatrix} 2 & 1 \\ 2 & 1 \end{bmatrix} \Rightarrow \vec v_2 = \begin{bmatrix} 1 \\ -2 \end{bmatrix}.

Step 3: assemble. Put the eigenvectors in the columns of PP and the eigenvalues in DD, in matching order:

P=[111−2],D=[5002],P−1=1−3[−2−1−11]=13[211−1].P = \begin{bmatrix} 1 & 1 \\ 1 & -2 \end{bmatrix},\quad D = \begin{bmatrix} 5 & 0 \\ 0 & 2 \end{bmatrix},\quad P^{-1} = \frac{1}{-3}\begin{bmatrix} -2 & -1 \\ -1 & 1 \end{bmatrix} = \frac13\begin{bmatrix} 2 & 1 \\ 1 & -1 \end{bmatrix}.

Step 4: check. PD=[525−4]PD = \begin{bmatrix} 5 & 2 \\ 5 & -4 \end{bmatrix}, and

PDP−1=13[525−4][211−1]=13[12369]=[4123].  ✓PDP^{-1} = \frac13\begin{bmatrix} 5 & 2 \\ 5 & -4 \end{bmatrix}\begin{bmatrix} 2 & 1 \\ 1 & -1 \end{bmatrix} = \frac13\begin{bmatrix} 12 & 3 \\ 6 & 9 \end{bmatrix} = \begin{bmatrix} 4 & 1 \\ 2 & 3 \end{bmatrix}. \;✓

The factorization isn’t unique. You can rescale any eigenvector (that rescales a column of PP and is undone by P−1P^{-1}), or list the eigenpairs in a different order, which permutes the columns of PP and the diagonal of DD together. The diagonal entries of DD, the eigenvalues, are the only fixed part.

✅ Concept check

You diagonalize $A = PDP^{-1}$, then swap the two columns of $P$ but leave $D$ alone. What happens?

Computing powers: Aⁿ = PDⁿP⁻¹

Here’s the payoff. Multiply AA by itself and the inner factors cancel:

A2=(PDP−1)(PDP−1)=PD (P−1P) DP−1=PD2P−1,An=PDnP−1.A^2 = (PDP^{-1})(PDP^{-1}) = PD\,(P^{-1}P)\,DP^{-1} = PD^2P^{-1}, \qquad A^n = PD^nP^{-1}.

Powers of a diagonal matrix are trivial: Dn=diag⁡(λ1n,…,λnn)D^n = \operatorname{diag}(\lambda_1^n, \dots, \lambda_n^n). Geometrically, nn applications of AA are nn round trips into eigen-coordinates, but all the intermediate trips cancel, so you go in once, scale nn times, and come back once.

For the worked example,

An=13[111−2][5n002n][211−1]=13[2⋅5n+2n5n−2n2⋅5n−2⋅2n5n+2⋅2n].A^n = \frac13\begin{bmatrix} 1 & 1 \\ 1 & -2 \end{bmatrix}\begin{bmatrix} 5^n & 0 \\ 0 & 2^n \end{bmatrix}\begin{bmatrix} 2 & 1 \\ 1 & -1 \end{bmatrix} = \frac13\begin{bmatrix} 2\cdot 5^n + 2^n & 5^n - 2^n \\ 2\cdot 5^n - 2\cdot 2^n & 5^n + 2\cdot 2^n \end{bmatrix}.

Check at n=2n = 2: the formula gives 13[54214233]=[1871411]\tfrac13\begin{bmatrix} 54 & 21 \\ 42 & 33\end{bmatrix} = \begin{bmatrix} 18 & 7 \\ 14 & 11 \end{bmatrix}, and multiplying A⋅AA\cdot A directly gives the same. For large nn, 5n5^n swamps 2n2^n, so An≈5n3[2121]A^n \approx \tfrac{5^n}{3}\begin{bmatrix} 2 & 1 \\ 2 & 1\end{bmatrix}. Every vector gets pulled toward the direction v⃗1=(1,1)\vec v_1 = (1,1). The dominant eigenvalue (the one with the largest ∣λ∣|\lambda|) wins, and that’s the reason power iteration from lesson 1.5 works.

Worked example: Fibonacci in closed form

The Fibonacci numbers 0,1,1,2,3,5,8,…0, 1, 1, 2, 3, 5, 8, \dots obey Fn+1=Fn+Fn−1F_{n+1} = F_n + F_{n-1}. Package two consecutive terms as a vector:

[Fn+1Fn]=[1110]⏟F[FnFn−1]⟹[Fn+1Fn]=Fn[10].\begin{bmatrix} F_{n+1} \\ F_n \end{bmatrix} = \underbrace{\begin{bmatrix} 1 & 1 \\ 1 & 0 \end{bmatrix}}_{F}\begin{bmatrix} F_n \\ F_{n-1} \end{bmatrix} \quad\Longrightarrow\quad \begin{bmatrix} F_{n+1} \\ F_n \end{bmatrix} = F^n\begin{bmatrix} 1 \\ 0 \end{bmatrix}.

The characteristic polynomial is λ2−λ−1=0\lambda^2 - \lambda - 1 = 0, so

φ=1+52≈1.618,ψ=1−52≈−0.618.\varphi = \frac{1+\sqrt5}{2} \approx 1.618, \qquad \psi = \frac{1-\sqrt5}{2} \approx -0.618 .

For an eigenvalue λ\lambda, the second row of F−λIF - \lambda I reads x−λy=0x - \lambda y = 0, so (λ,1)(\lambda, 1) is an eigenvector. Write the starting vector in eigen-coordinates. Since φ−ψ=5\varphi - \psi = \sqrt5,

[10]=15([φ1]−[ψ1]).\begin{bmatrix} 1 \\ 0 \end{bmatrix} = \frac{1}{\sqrt5}\left(\begin{bmatrix} \varphi \\ 1 \end{bmatrix} - \begin{bmatrix} \psi \\ 1 \end{bmatrix}\right).

Now each eigen-component just gets multiplied by its eigenvalue nn times:

Fn[10]=15(φn[φ1]−ψn[ψ1])⟹Fn=φn−ψn5F^n\begin{bmatrix} 1 \\ 0 \end{bmatrix} = \frac{1}{\sqrt5}\left(\varphi^n\begin{bmatrix} \varphi \\ 1 \end{bmatrix} - \psi^n\begin{bmatrix} \psi \\ 1 \end{bmatrix}\right) \quad\Longrightarrow\quad \boxed{F_n = \frac{\varphi^n - \psi^n}{\sqrt5}}

This is Binet’s formula. Check: F2=(φ2−ψ2)/5=(φ−ψ)(φ+ψ)/5=5⋅1/5=1F_2 = (\varphi^2 - \psi^2)/\sqrt5 = (\varphi - \psi)(\varphi + \psi)/\sqrt5 = \sqrt5\cdot 1/\sqrt5 = 1. ✓ Since ∣ψ∣<1|\psi| \lt 1, the ψn\psi^n term dies out, so FnF_n is the nearest integer to φn/5\varphi^n/\sqrt5 and Fn+1/Fn→φF_{n+1}/F_n \to \varphi, the golden ratio. The long-term growth rate is the dominant eigenvalue.

◆ Interactive Standard view vs eigenbasis view of x → Ax

Loading simulation…

Try these in the explorer:

  1. With the Skewed stretch preset, press Play. On the left, the iterates Anx⃗0A^n\vec x_0 sweep around and hug the v⃗1\vec v_1 line. On the right, the same points in eigen-coordinates move in a perfectly predictable way: c1c_1 doubles and c2c_2 halves every step. The readout shows Dnc⃗0D^n\vec c_0 computed by hand.
  2. Pick Fibonacci and step nn up. Watch the ratio x/yx/y in the readout approach 1.6181.618. On the right, the c2c_2 component flips sign each step because ψ<0\psi \lt 0, and it shrinks.
  3. Pick Negative eigenvalue. The left panel zig-zags, while the right panel shows the reason: c2c_2 is multiplied by −1-1 every step.
  4. Pick Shear and Rotation. The right panel can’t be drawn. Why is the subject of the next section.
  5. Pick Symmetric with the unit-circle checkbox on. The image ellipse’s axes lie exactly along the eigenvectors, which are perpendicular. Now drag the sliders to make b≠cb \neq c, and the ellipse axes come apart from the eigenvectors.
✏️ Pen & paperChange of basis in both directions●○○

Let B={(1,1),(1,2)}\mathcal B = \{(1,1), (1,2)\}.

  1. Find [x⃗]B[\vec x]_{\mathcal B} for x⃗=(3,5)\vec x = (3, 5).
  2. Which vector has B\mathcal B-coordinates (2,−1)(2, -1)?
  3. The transformation T(x,y)=(y,x)T(x, y) = (y, x) (reflection across y=xy = x) has standard matrix A=[0110]A = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}. Find its matrix [T]B[T]_{\mathcal B} and check that the trace and determinant agree with AA‘s.
Show worked solution

Here P=[1112]P = \begin{bmatrix} 1 & 1 \\ 1 & 2 \end{bmatrix} with det⁡P=1\det P = 1, so P−1=[2−1−11]P^{-1} = \begin{bmatrix} 2 & -1 \\ -1 & 1 \end{bmatrix}.

  1. [x⃗]B=P−1x⃗=(6−5, −3+5)=(1,2)[\vec x]_{\mathcal B} = P^{-1}\vec x = (6 - 5,\ -3 + 5) = (1, 2). Check: 1(1,1)+2(1,2)=(3,5)1(1,1) + 2(1,2) = (3, 5). ✓
  2. P(2,−1)=2(1,1)−1(1,2)=(1,0)P(2,-1) = 2(1,1) - 1(1,2) = (1, 0).
  3. AP=[1211]AP = \begin{bmatrix} 1 & 2 \\ 1 & 1 \end{bmatrix} (the reflection swaps each column’s entries), so
[T]B=P−1AP=[2−1−11][1211]=[130−1].[T]_{\mathcal B} = P^{-1}AP = \begin{bmatrix} 2 & -1 \\ -1 & 1 \end{bmatrix}\begin{bmatrix} 1 & 2 \\ 1 & 1 \end{bmatrix} = \begin{bmatrix} 1 & 3 \\ 0 & -1 \end{bmatrix}.

The trace is 00 and the determinant is −1-1, the same as AA. It’s triangular, so its eigenvalues 11 and −1-1 sit on the diagonal: a reflection fixes one line (λ=1\lambda = 1) and flips another (λ=−1\lambda = -1). The basis B\mathcal B isn’t the eigenbasis, so the matrix isn’t diagonal. The eigenbasis would be (1,1),(1,−1)(1,1), (1,-1).

✏️ Pen & paperA closed form for Aⁿ●●○

Let A=[1411]A = \begin{bmatrix} 1 & 4 \\ 1 & 1 \end{bmatrix}.

  1. Diagonalize AA.
  2. Find a formula for AnA^n and check it at n=2n = 2.
  3. Compute A10[21]A^{10}\begin{bmatrix} 2 \\ 1 \end{bmatrix} without multiplying any matrices.
Show worked solution
  1. det⁡(A−λI)=(1−λ)2−4=0\det(A - \lambda I) = (1-\lambda)^2 - 4 = 0 gives 1−λ=±21 - \lambda = \pm 2, so λ1=3\lambda_1 = 3 and λ2=−1\lambda_2 = -1. For λ=3\lambda = 3: A−3I=[−241−2]A - 3I = \begin{bmatrix} -2 & 4 \\ 1 & -2\end{bmatrix}, so v⃗1=(2,1)\vec v_1 = (2, 1). For λ=−1\lambda = -1: A+I=[2412]A + I = \begin{bmatrix} 2 & 4 \\ 1 & 2\end{bmatrix}, so v⃗2=(2,−1)\vec v_2 = (2, -1). Then
P=[221−1],D=[300−1],P−1=1−4[−1−2−12]=14[121−2].P = \begin{bmatrix} 2 & 2 \\ 1 & -1 \end{bmatrix},\quad D = \begin{bmatrix} 3 & 0 \\ 0 & -1\end{bmatrix},\quad P^{-1} = \frac{1}{-4}\begin{bmatrix} -1 & -2 \\ -1 & 2\end{bmatrix} = \frac14\begin{bmatrix} 1 & 2 \\ 1 & -2 \end{bmatrix}.
  1. An=PDnP−1=14[2⋅3n2(−1)n3n−(−1)n][121−2]=14[2⋅3n+2(−1)n4⋅3n−4(−1)n3n−(−1)n2⋅3n+2(−1)n].A^n = PD^nP^{-1} = \dfrac14\begin{bmatrix} 2\cdot 3^n & 2(-1)^n \\ 3^n & -(-1)^n\end{bmatrix}\begin{bmatrix} 1 & 2 \\ 1 & -2\end{bmatrix} = \dfrac14\begin{bmatrix} 2\cdot 3^n + 2(-1)^n & 4\cdot 3^n - 4(-1)^n \\ 3^n - (-1)^n & 2\cdot 3^n + 2(-1)^n \end{bmatrix}. At n=2n = 2 this is 14[2032820]=[5825]\tfrac14\begin{bmatrix} 20 & 32 \\ 8 & 20\end{bmatrix} = \begin{bmatrix} 5 & 8 \\ 2 & 5\end{bmatrix}. Directly, A2=[1+44+41+14+1]=[5825]A^2 = \begin{bmatrix} 1+4 & 4+4 \\ 1+1 & 4+1\end{bmatrix} = \begin{bmatrix} 5 & 8 \\ 2 & 5 \end{bmatrix}. ✓
  2. (2,1)(2,1) is the eigenvector v⃗1\vec v_1, so its eigen-coordinates are (1,0)(1, 0). Therefore A10(2,1)=310(2,1)=(118098, 59049)A^{10}(2,1) = 3^{10}(2,1) = (118098,\ 59049).

When diagonalization fails

Everything above needed nn independent eigenvectors to fill the columns of PP. That’s the whole criterion:

Why distinct eigenvalues suffice (2×2 case). Suppose λ1≠λ2\lambda_1 \neq \lambda_2 but v⃗2=c v⃗1\vec v_2 = c\,\vec v_1 were parallel. Then Av⃗2=cAv⃗1=cλ1v⃗1=λ1v⃗2A\vec v_2 = cA\vec v_1 = c\lambda_1\vec v_1 = \lambda_1\vec v_2. But also Av⃗2=λ2v⃗2A\vec v_2 = \lambda_2\vec v_2, so (λ1−λ2)v⃗2=0⃗(\lambda_1 - \lambda_2)\vec v_2 = \vec 0, which is impossible for a nonzero eigenvector. The same idea, applied by induction, works in any dimension: eigenvectors for different eigenvalues are always independent.

The defective shear. The video’s counterexample is

S=[1101],det⁡(S−λI)=(1−λ)2.S = \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}, \qquad \det(S - \lambda I) = (1 - \lambda)^2 .

The eigenvalue λ=1\lambda = 1 is repeated (algebraic multiplicity 2), but S−I=[0100]S - I = \begin{bmatrix} 0 & 1 \\ 0 & 0\end{bmatrix} has a one-dimensional kernel spanned by (1,0)(1, 0) (geometric multiplicity 1). Only horizontal vectors stay on their line, and every other direction gets sheared sideways. One eigenvector direction can’t make a basis of the plane, so SS is defective. Its powers betray this: Sn=[1n01]S^n = \begin{bmatrix} 1 & n \\ 0 & 1\end{bmatrix} grows linearly in nn, which no combination of λn=1n\lambda^n = 1^n terms could produce.

Repeated eigenvalues don’t automatically mean failure. 2I=[2002]2I = \begin{bmatrix} 2 & 0 \\ 0 & 2\end{bmatrix} has λ=2\lambda = 2 twice and is already diagonal, because every vector is an eigenvector. The question is always whether each eigenvalue has as many independent eigenvectors as its multiplicity. When it doesn’t, the best you can do is the Jordan form, which leads to solutions like teλtt e^{\lambda t} in 7.4 Complex & Repeated Eigenvalues.

Complex eigenvalues. The rotation [0−110]\begin{bmatrix} 0 & -1 \\ 1 & 0\end{bmatrix} has no real eigenvectors at all (it moves every direction), so it isn’t diagonalizable over R\mathbb R. Over C\mathbb C it has eigenvalues ±i\pm i and is diagonalizable. 1.7 Complex Eigenvalues & Rotation shows how to read the rotation off those complex eigenvalues.

✅ Concept checkselect all that apply

Which of these matrices are diagonalizable over the real numbers? Select all that apply.

✏️ Pen & paperDiagonalizable or defective?●●○

For each matrix, decide whether it is diagonalizable over R\mathbb R. Justify using eigenvalues and eigenspace dimensions.

  1. [3043]\begin{bmatrix} 3 & 0 \\ 4 & 3 \end{bmatrix}
  2. [200020007]\begin{bmatrix} 2 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 7 \end{bmatrix}
  3. [110021003]\begin{bmatrix} 1 & 1 & 0 \\ 0 & 2 & 1 \\ 0 & 0 & 3 \end{bmatrix}
  4. [1−21−1]\begin{bmatrix} 1 & -2 \\ 1 & -1 \end{bmatrix}
Show worked solution
  1. It’s triangular, with λ=3\lambda = 3 repeated. A−3I=[0040]A - 3I = \begin{bmatrix} 0 & 0 \\ 4 & 0\end{bmatrix} has kernel spanned by (0,1)(0, 1) only, which is one-dimensional. It’s defective (a vertical shear scaled by 3).
  2. It’s already diagonal, so it’s diagonalizable. λ=2\lambda = 2 has the two-dimensional eigenspace spanned by e⃗1,e⃗2\vec e_1, \vec e_2.
  3. It’s triangular with distinct eigenvalues 1,2,31, 2, 3, so it’s diagonalizable by the sufficient condition. No eigenvector computation is needed.
  4. The trace is 00 and the determinant is −1+2=1-1 + 2 = 1, so λ2+1=0\lambda^2 + 1 = 0 and λ=±i\lambda = \pm i. There are no real eigenvalues, so it’s not diagonalizable over R\mathbb R. Over C\mathbb C the eigenvalues are distinct, so it is diagonalizable there.

Symmetric matrices and the spectral theorem

The best possible case is a symmetric matrix, AT=AA^{\mathsf T} = A. These are everywhere in physics: stiffness matrices of spring networks and structures, inertia tensors, covariance matrices, stress tensors, and the discrete Laplacian that drives diffusion and pressure solves.

Why the eigenvectors are perpendicular. Take eigenpairs Av⃗1=λ1v⃗1A\vec v_1 = \lambda_1\vec v_1 and Av⃗2=λ2v⃗2A\vec v_2 = \lambda_2\vec v_2 with λ1≠λ2\lambda_1 \neq \lambda_2. Symmetry means (Au⃗)⋅w⃗=u⃗⋅(Aw⃗)(A\vec u)\cdot\vec w = \vec u\cdot(A\vec w) for all vectors. So

λ1(v⃗1⋅v⃗2)=(Av⃗1)⋅v⃗2=v⃗1⋅(Av⃗2)=λ2(v⃗1⋅v⃗2)  ⟹  (λ1−λ2)(v⃗1⋅v⃗2)=0.\lambda_1(\vec v_1\cdot\vec v_2) = (A\vec v_1)\cdot\vec v_2 = \vec v_1\cdot(A\vec v_2) = \lambda_2(\vec v_1\cdot\vec v_2) \;\Longrightarrow\; (\lambda_1 - \lambda_2)(\vec v_1\cdot\vec v_2) = 0 .

Since λ1≠λ2\lambda_1 \neq \lambda_2, we get v⃗1⋅v⃗2=0\vec v_1\cdot\vec v_2 = 0. For a 2×2 symmetric matrix [abbd]\begin{bmatrix} a & b \\ b & d\end{bmatrix}, the discriminant of the characteristic polynomial is (a−d)2+4b2≥0(a - d)^2 + 4b^2 \geq 0, so the eigenvalues are real. That’s the 2D version of point 1.

The change of basis is now especially nice. QQ is a rotation (possibly with a reflection), and converting into eigen-coordinates is just QTx⃗Q^{\mathsf T}\vec x, i.e. dot products with the eigenvectors, with no matrix inversion.

Worked example: principal axes of an ellipse

Take A=[2112]A = \begin{bmatrix} 2 & 1 \\ 1 & 2 \end{bmatrix}. Then λ2−4λ+3=0\lambda^2 - 4\lambda + 3 = 0 gives λ1=3\lambda_1 = 3 with q⃗1=12(1,1)\vec q_1 = \tfrac{1}{\sqrt2}(1, 1) and λ2=1\lambda_2 = 1 with q⃗2=12(1,−1)\vec q_2 = \tfrac{1}{\sqrt2}(1, -1). These are perpendicular, as promised. So

A=12[111−1]⏟Q[3001]12[111−1]⏟QT.A = \underbrace{\frac{1}{\sqrt2}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}}_{Q}\begin{bmatrix} 3 & 0 \\ 0 & 1 \end{bmatrix}\underbrace{\frac{1}{\sqrt2}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}}_{Q^{\mathsf T}} .

Picture 1: the image of the unit circle. AA sends the unit circle to an ellipse. Read QΛQTQ\Lambda Q^{\mathsf T} right to left: rotate the circle (which is still a circle), stretch by 3 and 1 along the axes, then rotate back. The result is an ellipse with semi-axes 3 along q⃗1\vec q_1 and 1 along q⃗2\vec q_2, which is what the video and the sim’s symmetric mode show.

Picture 2: a quadratic form. The curve x⃗TAx⃗=2x2+2xy+2y2=1\vec x^{\mathsf T}A\vec x = 2x^2 + 2xy + 2y^2 = 1 has an awkward xyxy cross term. In eigen-coordinates (u,v)=QTx⃗(u, v) = Q^{\mathsf T}\vec x,

x⃗TAx⃗=x⃗TQΛQTx⃗=(QTx⃗)TΛ(QTx⃗)=3u2+v2=1.\vec x^{\mathsf T}A\vec x = \vec x^{\mathsf T}Q\Lambda Q^{\mathsf T}\vec x = (Q^{\mathsf T}\vec x)^{\mathsf T}\Lambda(Q^{\mathsf T}\vec x) = 3u^2 + v^2 = 1 .

The cross term is gone. It’s an ellipse with semi-axis 1/31/\sqrt3 along q⃗1\vec q_1 and 11 along q⃗2\vec q_2. The eigenvectors are its principal axes. The same computation finds the principal stresses in a solid and the principal axes of a rigid body’s rotation, and it decides whether an equilibrium of a potential is a minimum or a saddle.

✏️ Pen & paperRotate away the cross term●●○

Find the principal axes and semi-axis lengths of the ellipse 5x2+4xy+2y2=65x^2 + 4xy + 2y^2 = 6.

Show worked solution

Write it as x⃗TAx⃗=6\vec x^{\mathsf T}A\vec x = 6 with A=[5222]A = \begin{bmatrix} 5 & 2 \\ 2 & 2 \end{bmatrix}. The 4xy4xy term splits evenly into the two off-diagonal entries. The trace is 77 and the determinant is 66, so λ2−7λ+6=0\lambda^2 - 7\lambda + 6 = 0 and λ=6,1\lambda = 6, 1.

  • λ=6\lambda = 6: A−6I=[−122−4]A - 6I = \begin{bmatrix} -1 & 2 \\ 2 & -4 \end{bmatrix}, so q⃗1=15(2,1)\vec q_1 = \tfrac{1}{\sqrt5}(2, 1).
  • λ=1\lambda = 1: A−I=[4221]A - I = \begin{bmatrix} 4 & 2 \\ 2 & 1 \end{bmatrix}, so q⃗2=15(1,−2)\vec q_2 = \tfrac{1}{\sqrt5}(1, -2).

Check: q⃗1⋅q⃗2=(2−2)/5=0\vec q_1\cdot\vec q_2 = (2 - 2)/5 = 0. ✓ In coordinates u,vu, v along q⃗1,q⃗2\vec q_1, \vec q_2, the equation becomes 6u2+v2=66u^2 + v^2 = 6, i.e. u2+v26=1u^2 + \dfrac{v^2}{6} = 1. The ellipse has semi-axis 11 along the direction (2,1)(2, 1) and semi-axis 6≈2.45\sqrt6 \approx 2.45 along (1,−2)(1, -2). The large eigenvalue gives the short axis, because the form grows fastest in that direction.

Decoupling coupled systems

Now we can say exactly what “diagonalization decouples” means. Take the coupled recurrence

xn+1=4xn+yn,yn+1=2xn+3yn,x_{n+1} = 4x_n + y_n, \qquad y_{n+1} = 2x_n + 3y_n,

i.e. x⃗n+1=Ax⃗n\vec x_{n+1} = A\vec x_n with the worked-example matrix A=[4123]A = \begin{bmatrix} 4 & 1 \\ 2 & 3\end{bmatrix}. Each new value depends on both old ones. Substitute eigen-coordinates x⃗n=Pc⃗n\vec x_n = P\vec c_n:

Pc⃗n+1=APc⃗n  ⟹  c⃗n+1=P−1AP c⃗n=Dc⃗n  ⟹  {c1,n+1=5 c1,nc2,n+1=2 c2,nP\vec c_{n+1} = AP\vec c_n \;\Longrightarrow\; \vec c_{n+1} = P^{-1}AP\,\vec c_n = D\vec c_n \;\Longrightarrow\; \begin{cases} c_{1,n+1} = 5\,c_{1,n} \\ c_{2,n+1} = 2\,c_{2,n} \end{cases}

These are two independent scalar recurrences, each solved by inspection: c1,n=5nc1,0c_{1,n} = 5^n c_{1,0} and c2,n=2nc2,0c_{2,n} = 2^n c_{2,0}. Concretely, from P−1=13[211−1]P^{-1} = \frac13\begin{bmatrix} 2 & 1 \\ 1 & -1\end{bmatrix}, the eigen-coordinates are the special combinations c1=13(2x+y)c_1 = \tfrac13(2x + y) and c2=13(x−y)c_2 = \tfrac13(x - y). You can verify directly that 2xn+1+yn+1=10xn+5yn=5(2xn+yn)2x_{n+1} + y_{n+1} = 10x_n + 5y_n = 5(2x_n + y_n), and xn+1−yn+1=2xn−2yn=2(xn−yn)x_{n+1} - y_{n+1} = 2x_n - 2y_n = 2(x_n - y_n). Diagonalization found the combinations of variables that evolve on their own.

The ODE version is identical. For x⃗′=Ax⃗\vec x' = A\vec x, substituting x⃗=Pc⃗\vec x = P\vec c gives c⃗′=Dc⃗\vec c' = D\vec c, so ci′=λicic_i' = \lambda_i c_i and ci(t)=eλitci(0)c_i(t) = e^{\lambda_i t}c_i(0). Translating back,

x⃗(t)=c1(0)eλ1tv⃗1+⋯+cn(0)eλntv⃗n,equivalentlyx⃗(t)=PeDtP−1x⃗(0).\vec x(t) = c_1(0)e^{\lambda_1 t}\vec v_1 + \cdots + c_n(0)e^{\lambda_n t}\vec v_n, \qquad\text{equivalently}\qquad \vec x(t) = Pe^{Dt}P^{-1}\vec x(0).

That matrix PeDtP−1Pe^{Dt}P^{-1} is the matrix exponential eAte^{At}, previewed in 1.8 The Matrix Exponential: From Hops to Flows and used as the main solution method in 7.2 Linear Systems & the Eigenvalue Method.

Worked example: two masses, three springs

Two equal masses mm sit between two walls, joined by three identical springs of stiffness kk. Let x1,x2x_1, x_2 be their displacements. Newton’s law, with k=m=1k = m = 1, gives

x¨1=−x1+(x2−x1)=−2x1+x2,x¨2=−(x2−x1)−x2=x1−2x2,\ddot x_1 = -x_1 + (x_2 - x_1) = -2x_1 + x_2, \qquad \ddot x_2 = -(x_2 - x_1) - x_2 = x_1 - 2x_2,

i.e. x⃗¨=−Kx⃗\ddot{\vec x} = -K\vec x with the symmetric stiffness matrix K=[2−1−12]K = \begin{bmatrix} 2 & -1 \\ -1 & 2 \end{bmatrix}. Its eigenpairs are λ=1\lambda = 1 with (1,1)(1, 1) and λ=3\lambda = 3 with (1,−1)(1, -1), which are perpendicular as the spectral theorem promises. In eigen-coordinates q1=x1+x2q_1 = x_1 + x_2 and q2=x1−x2q_2 = x_1 - x_2 (up to normalization),

q¨1=−q1,q¨2=−3q2.\ddot q_1 = -q_1, \qquad \ddot q_2 = -3q_2 .

These are two independent simple harmonic oscillators, the normal modes. In mode 1 the masses swing together at ω=1\omega = 1, and the middle spring never stretches. In mode 2 they swing in opposition at the faster ω=3\omega = \sqrt3. Every motion of the system is a superposition of these two. The full theory, with damping and NN masses, is in 14.1 Coupled Oscillators & Normal Modes.

✏️ Pen & paperCity and suburbs: long-run populations●●●

Each year, 10% of city dwellers move to the suburbs and 20% of suburbanites move to the city. Initially 1000 people live in the city and none in the suburbs. With x⃗n=(cityn,suburbsn)\vec x_n = (\text{city}_n, \text{suburbs}_n):

  1. Write x⃗n+1=Mx⃗n\vec x_{n+1} = M\vec x_n.
  2. Diagonalize MM and find a closed form for x⃗n\vec x_n.
  3. What happens as n→∞n \to \infty? How fast does it get there?
Show worked solution
  1. City next year = 90% of the city + 20% of the suburbs, and similarly for the suburbs:
M=[0.90.20.10.8].M = \begin{bmatrix} 0.9 & 0.2 \\ 0.1 & 0.8 \end{bmatrix}.

Each column sums to 1, because nobody is created or destroyed. This makes MM a Markov matrix. 2. The trace is 1.71.7 and the determinant is 0.72−0.02=0.70.72 - 0.02 = 0.7, so λ2−1.7λ+0.7=(λ−1)(λ−0.7)\lambda^2 - 1.7\lambda + 0.7 = (\lambda - 1)(\lambda - 0.7) and λ1=1\lambda_1 = 1, λ2=0.7\lambda_2 = 0.7. Eigenvectors: M−I=[−0.10.20.1−0.2]M - I = \begin{bmatrix} -0.1 & 0.2 \\ 0.1 & -0.2\end{bmatrix} gives v⃗1=(2,1)\vec v_1 = (2, 1), and M−0.7I=[0.20.20.10.1]M - 0.7I = \begin{bmatrix} 0.2 & 0.2 \\ 0.1 & 0.1\end{bmatrix} gives v⃗2=(1,−1)\vec v_2 = (1, -1). Eigen-coordinates of x⃗0=(1000,0)\vec x_0 = (1000, 0): solve 2a+b=10002a + b = 1000 and a−b=0a - b = 0, so a=b=1000/3a = b = 1000/3. Therefore

x⃗n=10003[[21]+(0.7)n[1−1]].\vec x_n = \frac{1000}{3}\left[\begin{bmatrix} 2 \\ 1 \end{bmatrix} + (0.7)^n\begin{bmatrix} 1 \\ -1 \end{bmatrix}\right].

Check at n=1n = 1: 10003(2.7,0.3)=(900,100)\tfrac{1000}{3}(2.7, 0.3) = (900, 100), which matches Mx⃗0=(900,100)M\vec x_0 = (900, 100). ✓ 3. (0.7)n→0(0.7)^n \to 0, so x⃗n→(666.6‾, 333.3‾)\vec x_n \to (666.\overline{6},\ 333.\overline{3}), a 2 : 1 split in the direction of the λ=1\lambda = 1 eigenvector, whatever the initial split was (only the total population matters). The deviation from equilibrium shrinks by a factor of 0.70.7 per year, so after about ln⁡(100)/ln⁡(1/0.7)≈13\ln(100)/\ln(1/0.7) \approx 13 years it’s within 1% of its initial size. The second eigenvalue sets the convergence rate.

Diagonalization in code

NumPy’s np.linalg.eig returns the eigenvalues and a matrix whose columns are unit eigenvectors, which is exactly the DD and PP of the factorization. For symmetric matrices, use np.linalg.eigh, which guarantees real eigenvalues and orthonormal eigenvectors.

🐍 PythonDiagonalize, take powers, and check Binet's formula
⌘/Ctrl + Enter

Now implement the factorization yourself. Your power_by_eig should build PDnP−1PD^nP^{-1} from the eigenpairs. Because it only needs λn\lambda^n, it even works for fractional nn when the eigenvalues are positive, giving a matrix square root, which repeated multiplication can’t do.

🧪 Coding exerciseExercise: matrix powers two ways
⌘/Ctrl + Enter

The second exercise decouples a recurrence. The sequence an+1=an+2bna_{n+1} = a_n + 2b_n, bn+1=anb_{n+1} = a_n is x⃗n+1=Ax⃗n\vec x_{n+1} = A\vec x_n with A=[1210]A = \begin{bmatrix} 1 & 2 \\ 1 & 0\end{bmatrix}. Predict x⃗n\vec x_n by working in eigen-coordinates (no matrix powers allowed), and predict the long-term ratio an/bna_n / b_n from the dominant eigenvector alone.

🧪 Coding exerciseExercise: decouple a recurrence and predict its long-term ratio
⌘/Ctrl + Enter

Finally, see the fluids claim numerically: the FFT matrix diagonalizes the periodic discrete Laplacian, and in Fourier space diffusion is just independent decay.

🐍 PythonThe FFT diagonalizes the periodic Laplacian
⌘/Ctrl + Enter

Key Takeaways

  • The same linear transformation has different matrices in different bases. If PP has the new basis vectors as columns, then x⃗=P[x⃗]B\vec x = P[\vec x]_{\mathcal B} and [x⃗]B=P−1x⃗[\vec x]_{\mathcal B} = P^{-1}\vec x.
  • Similar matrices B=P−1APB = P^{-1}AP are one transformation in two languages. They share eigenvalues, determinant and trace.
  • If AA has nn independent eigenvectors, then A=PDP−1A = PDP^{-1}. Read right to left: into eigen-coordinates, scale each axis by its λ\lambda, and back.
  • Powers become trivial: An=PDnP−1A^n = PD^nP^{-1}. The dominant eigenvalue sets the long-run growth and direction (Fibonacci gives φ\varphi), and the next-largest sets how fast you get there.
  • A matrix is diagonalizable exactly when it has nn independent eigenvectors. Distinct eigenvalues guarantee it. The shear is the classic defective counterexample, and rotations need complex numbers.
  • Spectral theorem: real symmetric matrices have real eigenvalues and orthonormal eigenvectors, A=QΛQTA = Q\Lambda Q^{\mathsf T}. The eigenvectors are the principal axes of the associated ellipse.
  • In the eigenbasis, coupled recurrences and ODE systems split into independent scalar problems. For ODEs, eAt=PeDtP−1e^{At} = Pe^{Dt}P^{-1}.
  • Normal modes of structures and Fourier modes on periodic grids are eigenbases. The FFT diagonalizes the periodic Laplacian, which makes spectral fluid solvers fast.
Finished this lesson?

Mark it complete to track your progress (saved in this browser). Reading every section does this for you.