Diagonalization
A matrix like A = \begin{bmatrix} 2 & 1 \\ 1 & 2 \end{bmatrix} looks
genuinely tangled: multiply it into a vector and both coordinates get mixed together. But put on
the right glasses — view the plane using A's own
eigenvectors as
the coordinate axes instead of the usual x- and
y-axes — and the tangle disappears. In that special basis,
A does nothing but stretch each axis by its own eigenvalue. No mixing,
no rotation, just plain multiplication along two independent directions.
That change of glasses is called diagonalization, and it is written as a single
compact equation:
A = P D P^{-1},
where the columns of P are the eigenvectors and
D is the diagonal matrix of the matching eigenvalues. Read the right-hand
side right to left: P^{-1} rewrites a vector in eigen-coordinates,
D stretches along each eigen-axis, and P
translates the result back into ordinary coordinates. This isn't just a tidy formula — it's the key
that turns "apply this matrix a hundred times" into "raise two numbers to the hundredth power," as
the payoff below shows.
Built from one idea, repeated for every eigenvector at once
The whole recipe falls out of a single fact you already know: apply A to
one of its own eigenvectors, and it doesn't rotate or twist — it just scales,
A\vec{v} = \lambda\vec{v}. Now do that for every eigenvector at
once, packing them side by side as the columns of a matrix P. Applying
A to each column separately is exactly the same as multiplying
A by the whole matrix P:
AP = A\begin{bmatrix} \vert & & \vert \\ \vec{v}_1 & \cdots & \vec{v}_n \\ \vert & & \vert \end{bmatrix} = \begin{bmatrix} \vert & & \vert \\ \lambda_1\vec{v}_1 & \cdots & \lambda_n\vec{v}_n \\ \vert & & \vert \end{bmatrix} = P D.
Each column just picked up its own scale factor — and multiplying a matrix by a diagonal matrix
on the right is exactly "scale column i by
D's i-th entry." That's precisely what
PD means. So AP = PD. As long as
P is invertible — which it is exactly when the eigenvectors are
independent — multiply both sides on the right by P^{-1} and out pops
A = PDP^{-1}. No new ideas were needed: just "eigenvectors scale," applied
to every eigen-direction simultaneously.
-
An n \times n matrix A is diagonalizable
exactly when it has n linearly independent eigenvectors.
-
When it does, A = PDP^{-1}, with P's
columns the eigenvectors and D the diagonal matrix of the matching
eigenvalues — in the same order.
-
Then A^k = PD^kP^{-1} for every whole number
k: raising A to a power is just raising
its eigenvalues to that power.
A stretch along its own axes
The faint grid below is aligned to the eigenvectors of
A = \begin{bmatrix} 2 & 1 \\ 1 & 2 \end{bmatrix} — the very matrix we'll
diagonalize by hand next. Drag the slider to apply A: the grid doesn't
rotate or shear, it simply stretches — ×3 along one eigen-axis, ×1 (unchanged) along the other. Seen
through the eigenvectors' eyes, this matrix was never complicated at all.
Worked example: diagonalize a 2×2 matrix, start to finish
Take A = \begin{bmatrix} 2 & 1 \\ 1 & 2 \end{bmatrix} and walk the whole
recipe through by hand.
Step 1 — eigenvalues from the
characteristic
equation. Solve \det(A - \lambda I) = 0:
(2-\lambda)^2 - 1 = 0 \;\Longrightarrow\; \lambda^2 - 4\lambda + 3 = 0 \;\Longrightarrow\; (\lambda - 3)(\lambda - 1) = 0.
So \lambda_1 = 3 and \lambda_2 = 1.
Step 2 — eigenvectors via the null-space method. For each
\lambda, solve (A - \lambda I)\vec{v} = \vec{0}.
For \lambda_1 = 3:
\begin{bmatrix} -1 & 1 \\ 1 & -1 \end{bmatrix}\vec{v} = \vec{0} gives
v_2 = v_1, so \vec{v}_1 = \begin{bmatrix}1\\1\end{bmatrix}.
For \lambda_2 = 1:
\begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix}\vec{v} = \vec{0} gives
v_2 = -v_1, so \vec{v}_2 = \begin{bmatrix}1\\-1\end{bmatrix}.
Step 3 — assemble P and D,
eigenvectors as columns of P, eigenvalues in the matching order
along D:
P = \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}, \qquad D = \begin{bmatrix} 3 & 0 \\ 0 & 1 \end{bmatrix}.
Inverting the 2×2 matrix P (determinant -2)
gives P^{-1} = \begin{bmatrix} 1/2 & 1/2 \\ 1/2 & -1/2 \end{bmatrix}.
Step 4 — verify. Multiply it back out:
PDP^{-1} = \begin{bmatrix} 3 & 1 \\ 3 & -1 \end{bmatrix}\begin{bmatrix} 1/2 & 1/2 \\ 1/2 & -1/2 \end{bmatrix} = \begin{bmatrix} 2 & 1 \\ 1 & 2 \end{bmatrix} = A. \checkmark
It really does come back to A. Every step was ordinary
matrix
multiplication — the cleverness was all in choosing P and
D correctly in the first place.
The payoff: A^100 in three easy pieces
Here is why anyone bothers with all of this. Suppose you need
A^5 for the same matrix. Multiplying A by
itself five times by hand is tedious and the numbers grow messy fast. Diagonalization sidesteps all
of it:
A^5 = (PDP^{-1})^5 = PD^5P^{-1},
because every inner P^{-1}P pair cancels to the identity, leaving only
the outer P and P^{-1} and a chain of
D's. And a diagonal matrix to a power is trivial — just raise
each entry:
D^5 = \begin{bmatrix} 3^5 & 0 \\ 0 & 1^5 \end{bmatrix} = \begin{bmatrix} 243 & 0 \\ 0 & 1 \end{bmatrix}.
Multiplying back out gives the exact answer with no repeated matrix-by-matrix grinding:
A^5 = PD^5P^{-1} = \begin{bmatrix} 122 & 121 \\ 121 & 122 \end{bmatrix}.
(Quick sanity check: the trace 122+122=244 matches
3^5+1^5, and the determinant 122^2-121^2=243
matches 3^5\cdot1^5. It checks out.)
Now imagine wanting A^{100} instead of A^5.
Multiplying the matrix by itself, entry by entry, ninety-nine more times (or even using repeated
squaring) is a real computation with numbers exploding in size at every step. Diagonalized, nothing
changes in difficulty at all: D^{100} just needs
3^{100} and 1^{100} — two numbers raised to a
power, done once — sandwiched between the same fixed P and
P^{-1} as before. That single trick evaluates matrix powers instantly,
solves systems of differential equations, computes the long-run behaviour of Markov processes, and
sets up the
decompositions
that data science leans on. Eigenvectors turn "apply this matrix a hundred times" into "raise two
numbers to the hundredth power."
Diagonalization is powerful but has real limits — and an easy-to-miss bookkeeping trap.
-
Not every matrix is diagonalizable. Take
B = \begin{bmatrix} 2 & 1 \\ 0 & 2 \end{bmatrix}. Its only eigenvalue is
\lambda = 2 (repeated), but solving
(B - 2I)\vec{v} = \vec{0} gives
\begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix}\vec{v} = \vec{0}, forcing
v_2 = 0 — every eigenvector points along
(1,0). There is only one independent eigen-direction where a
2×2 matrix needs two, so there's no way to build an invertible
P. Such a matrix is called defective, and it genuinely
cannot be written as PDP^{-1}.
-
The order of the columns must match. P's first column
must be the eigenvector for D's first diagonal entry, and so on. Swap
the eigenvectors in P without swapping the eigenvalues in
D to match, and you get a perfectly matrix-shaped answer that is
simply wrong — it multiplies out to a different matrix than
A entirely, with no error message to warn you.
Population models, weather models, and Google's original PageRank algorithm all
work the same way: take a state vector (populations in each age group, the chance of being in each
weather condition, how much "importance" each web page holds) and repeatedly multiply it by a
transition matrix to step it forward one year, one day, one link-click at a time.
Simulating that year by year for centuries would be painfully slow — but diagonalization says you
don't have to. The state after n steps is
A^n\vec{x}_0 = PD^nP^{-1}\vec{x}_0, and since most transition matrices
have eigenvalues with size at most 1, every eigenvalue smaller than 1 gets crushed towards zero as
n grows in D^n, while the largest eigenvalue
(exactly 1, for a well-behaved transition matrix) survives untouched. That's why the state
settles into a single stable distribution — the "long-run population split," or the final PageRank
scores — instead of wandering forever. Diagonalization doesn't just compute the far future in one
step; it explains why there's a stable far future to compute at all.
A tiny taste of it: a toy weather model might say "if it's sunny today, it's sunny again tomorrow
with probability 0.6; if it's rainy today, it stays rainy with probability 0.6." That transition
matrix has eigenvalues 1 and 0.2. Raise it to
the n-th power via PD^nP^{-1} and the
0.2^n term shrinks towards nothing within a couple of weeks, leaving only
the eigenvalue-1 term — the long-run 50/50 split between sun and rain. No matter where the weather
starts, diagonalization says exactly how fast it forgets, and exactly what it settles into.