Skip to content

How to diagonalize a matrix

6 min read

Short answer

To diagonalize an n×nn\times n matrix AA, find its eigenvalues, find nn independent eigenvectors, put them as the columns of PP, and put the matching eigenvalues on the diagonal of DD. Then A=PDP−1A=PDP^{-1}. It works exactly when there are nn independent eigenvectors.

Steps1Solve det(A − λI) = 0 for the eigenvalues2For each λ, solve (A − λI)v= 0 for eigenvectors3Check you have n independent eigenvectors4P = eigenvectors as columns, D = eigenvaluesThen A = P D P⁻¹ and Aᵏ = P Dᵏ P⁻¹
Diagonalization is just eigenvalue work organized into two matrices. Keep the eigenvector order consistent with the eigenvalue order.

When it fails

If an eigenvalue is repeated, it may have fewer independent eigenvectors than its multiplicity; then the matrix is defective and cannot be diagonalized. Distinct eigenvalues guarantee success. Symmetric matrices are always diagonalizable, with an orthogonal PP.

Why bother

Diagonal matrices are easy: DkD^k just raises each diagonal entry to the power kk. Therefore Ak=PDkP−1A^k=PD^kP^{-1}, which makes long-term behavior of systems and recurrences, like Markov chains or Fibonacci numbers, easy to compute.

Worked example

Diagonalize A=(4123)A=\begin{pmatrix}4&1\\2&3\end{pmatrix}.

Trace =7=7 and determinant =10=10, so λ2−7λ+10=0\lambda^2-7\lambda+10=0 gives λ=5\lambda=5 and λ=2\lambda=2.

λ=5\lambda=5: (A−5I)=(−112−2)(A-5I)=\begin{pmatrix}-1&1\\2&-2\end{pmatrix}, eigenvector (1,1)(1,1). λ=2\lambda=2: (A−2I)=(2121)(A-2I)=\begin{pmatrix}2&1\\2&1\end{pmatrix}, eigenvector (1,−2)(1,-2).

P=(111−2),D=(5002),A=PDP−1.P=\begin{pmatrix}1&1\\1&-2\end{pmatrix},\quad D=\begin{pmatrix}5&0\\0&2\end{pmatrix},\quad A=PDP^{-1}. Check with the trace of A2A^2: tr⁡A2=52+22=29\operatorname{tr}A^2=5^2+2^2=29, and directly A2=(1871411)A^2=\begin{pmatrix}18&7\\14&11\end{pmatrix} has trace 29. ✓

Try it yourself

Is (1101)\begin{pmatrix}1&1\\0&1\end{pmatrix} diagonalizable?

Show the answer

No. The only eigenvalue is 1 (repeated), and (A−I)v=0(A-I)\mathbf v=\mathbf 0 gives v2=0v_2=0, so there is only one independent eigenvector (1,0)(1,0), but we need two.

Keep going with practice

Diagonalization follows eigenvalues in Vidi's Linear Algebra & Probability course, and the matrix calculator can check your P and D.