Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools

How to Diagonalize a Matrix

To diagonalize AA is to write A=PDP−1A = PDP^{-1} with DD diagonal. The columns of PP are independent eigenvectors and the diagonal of DD holds their eigenvalues, in the same order.

Recognize the task

The question says diagonalize, "find PP and DD", "find an invertible PP with P−1APP^{-1}AP diagonal", or "write A=PDP−1A = PDP^{-1}": (5412)\begin{pmatrix} 5 & 4 \\ 1 & 2 \end{pmatrix}, a 3×33 \times 3 with three distinct eigenvalues, a 3×33 \times 3 with a repeated eigenvalue. Test: you need nn independent eigenvectors; if a repeated eigenvalue falls short, stop (see the diagonalizability check).
The procedure is Constructing the Diagonalization; the factorization is the diagonalization formula.

Two ways to do it

General: A = PDP⁻¹any diagonalizable A
A=PDP−1,P=[ v1 ⋯ vn ],D=diag⁡(λ1,…,λn)A = PDP^{-1}, \quad P = [\,\mathbf{v}_1 \ \cdots \ \mathbf{v}_n\,], \quad D = \operatorname{diag}(\lambda_1, \ldots, \lambda_n)
Invert PP with the 2×2 inverse formula or by Gauss–Jordan.
Symmetric: A = QDQᵀA = Aᵀ
A=QDQT,Q−1=QTA = QDQ^T, \quad Q^{-1} = Q^T
Normalize orthogonal eigenvectors and no inverse is needed: the spectral decomposition, guaranteed by the spectral theorem.

Steps

StepOn A=(5412)A = \begin{pmatrix} 5 & 4 \\ 1 & 2 \end{pmatrix}
1Find the eigenvalues. Solve det⁡(A−λI)=0\det(A - \lambda I) = 0, as in finding eigenvalues.λ2−7λ+6=0\lambda^2 - 7\lambda + 6 = 0: λ=6,1\lambda = 6, 1
2Find a basis of each eigenspace. Row reduce A−λIA - \lambda I, as in finding eigenvectors.λ=6\lambda = 6: (4,1)(4, 1); λ=1\lambda = 1: (1,−1)(1, -1)
3Count the eigenvectors. You need nn of them; eigenvectors for distinct eigenvalues are independent. Fewer than nn means AA is not diagonalizable: stop.22 vectors for n=2n = 2 ✓
4Build PP and DD in matching order. Column jj of PP is the eigenvector for the jj-th diagonal entry of DD.P=(411−1)P = \begin{pmatrix} 4 & 1 \\ 1 & -1 \end{pmatrix}, D=(6001)D = \begin{pmatrix} 6 & 0 \\ 0 & 1 \end{pmatrix}
5Find P−1P^{-1} and check AP=PDAP = PD. Checking AP=PDAP = PD needs no inverse; you still need P−1P^{-1} to write A=PDP−1A = PDP^{-1}.P−1=15(111−4)P^{-1} = \frac{1}{5}\begin{pmatrix} 1 & 1 \\ 1 & -4 \end{pmatrix}; AP=PD=(2416−1)AP = PD = \begin{pmatrix} 24 & 1 \\ 6 & -1 \end{pmatrix} ✓

Worked examples

Example 1 · a symmetric matrix

2×2
A=(1331)A = \begin{pmatrix} 1 & 3 \\ 3 & 1 \end{pmatrix}: λ=4\lambda = 4, (1,1)(1, 1); λ=−2\lambda = -2, (1,−1)(1, -1)
P=(111−1)P = \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}, D=(400−2)D = \begin{pmatrix} 4 & 0 \\ 0 & -2 \end{pmatrix}
eigenvectors as columns
P−1=12(111−1)P^{-1} = \frac{1}{2}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}, A=PDP−1A = PDP^{-1}
det⁡P=−2\det P = -2

Example 2 · three distinct eigenvalues

3×3
A=(401−210−201)A = \begin{pmatrix} 4 & 0 & 1 \\ -2 & 1 & 0 \\ -2 & 0 & 1 \end{pmatrix}: λ=1,2,3\lambda = 1, 2, 3
distinct, so diagonalizable
eigenvectors (0,1,0)(0, 1, 0), (1,−2,−2)(1, -2, -2), (−1,1,1)(-1, 1, 1)
one per eigenvalue
P=(01−11−210−21)P = \begin{pmatrix} 0 & 1 & -1 \\ 1 & -2 & 1 \\ 0 & -2 & 1 \end{pmatrix}, D=diag⁡(1,2,3)D = \operatorname{diag}(1, 2, 3)
P−1=(01−1−10−1−20−1)P^{-1} = \begin{pmatrix} 0 & 1 & -1 \\ -1 & 0 & -1 \\ -2 & 0 & -1 \end{pmatrix}; AP=PDAP = PD ✓
det⁡P=1\det P = 1

Example 3 · a repeated eigenvalue

3×3, double λ
A=(200020103)A = \begin{pmatrix} 2 & 0 & 0 \\ 0 & 2 & 0 \\ 1 & 0 & 3 \end{pmatrix}: E2=span⁡{(−1,0,1),(0,1,0)}E_2 = \operatorname{span}\{(-1, 0, 1), (0, 1, 0)\}
two free variables
λ=3\lambda = 3: E3=span⁡{(0,0,1)}E_3 = \operatorname{span}\{(0, 0, 1)\}
P=(−100010101)P = \begin{pmatrix} -1 & 0 & 0 \\ 0 & 1 & 0 \\ 1 & 0 & 1 \end{pmatrix}, D=diag⁡(2,2,3)D = \operatorname{diag}(2, 2, 3), P−1=PP^{-1} = P
check: P2=IP^2 = I
Step through PP, DD and P−1P^{-1} in the matrix diagonalization visualizer.

See it happen

Read A=PDP−1A = PDP^{-1} from right to left. P−1P^{-1} converts a vector into eigenvector coordinates, DD stretches each coordinate by its eigenvalue, and PP converts back. In the eigenvector basis the matrix does nothing but scale along the axes; all the mixing in AA comes from describing that simple action in the standard coordinates. Diagonalizing is a change of basis to the basis where AA is simplest.

Common mistakes

Swapping P and its inverse

✗ P−1DP=(5142)P^{-1}DP = \begin{pmatrix} 5 & 1 \\ 4 & 2 \end{pmatrix}, which is not AA
✓ A=PDP−1A = PDP^{-1}, with the eigenvectors as the columns of PP

Mismatched order

✗ P=(411−1)P = \begin{pmatrix} 4 & 1 \\ 1 & -1 \end{pmatrix} with D=diag⁡(1,6)D = \operatorname{diag}(1, 6)
✓ the eigenvector (4,1)(4, 1) belongs to 66: D=diag⁡(6,1)D = \operatorname{diag}(6, 1)
The mismatched product PDP−1PDP^{-1} is (2−4−15)\begin{pmatrix} 2 & -4 \\ -1 & 5 \end{pmatrix}, not AA.

Forcing a defective matrix

✗ (3103)\begin{pmatrix} 3 & 1 \\ 0 & 3 \end{pmatrix}: P=(1100)P = \begin{pmatrix} 1 & 1 \\ 0 & 0 \end{pmatrix}, D=3ID = 3I
✓ that PP is singular; with only one eigenvector direction the matrix is not diagonalizable