Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

Recipe

Diagonalize a matrix

Use when: you're given a square matrix A and asked to find P and D with A=PDP^{-1}, D diagonal

Goal: the eigenvalues plus enough independent eigenvectors to fill D and P, or a confirmed conclusion that A can't be diagonalized

Taught in Diagonalization · a later section extends this recipe with more cases

  1. 1

    Solve the characteristic equation \det(A-\lambda I)=0 for \lambda.

    Example

    Take A = \begin{bmatrix} 7 & 2 \\ -3 & 2 \end{bmatrix}, the matrix from the widget above. Its characteristic equation is \lambda^2 - \operatorname{tr}(A)\lambda + \det(A) = \lambda^2 - 9\lambda + 20 = 0, using \operatorname{tr}(A) = 7+2=9 and \det(A)=(7)(2)-(2)(-3)=20. That factors as (\lambda-5)(\lambda-4)=0, so \lambda = 5 \quad\text{or}\quad \lambda = 4

    Why: P's columns and D's diagonal entries are built entirely out of A's eigenpairs, so those have to be found first.

  2. 2

    For each \lambda, solve (A-\lambda I)\mathbf v=\mathbf 0; the nonzero solutions are the eigenvectors for that \lambda.

    Example

    For \lambda=5: A - 5I = \begin{bmatrix} 2 & 2 \\ -3 & -3 \end{bmatrix}, giving 2x_1+2x_2=0, i.e. x_1=-x_2, so v_1 = \begin{bmatrix} 1 \\ -1 \end{bmatrix}. For \lambda=4: A-4I = \begin{bmatrix} 3 & 2 \\ -3 & -2 \end{bmatrix}, giving 3x_1+2x_2=0, so v_2 = \begin{bmatrix} 2 \\ -3 \end{bmatrix} (pick x_1=2 to clear the fraction). Both match the eigenpairs the widget revealed.

    Why: these eigenvectors are exactly what fills P's columns in the next step.

  3. 3

    Count the independent eigenvectors gathered so far, across every eigenvalue.

    Example

    A is 2\times2, and v_1=\begin{bmatrix}1\\-1\end{bmatrix}, v_2=\begin{bmatrix}2\\-3\end{bmatrix} aren't scalar multiples of each other (their 2\times2 determinant (1)(-3)-(2)(-1) = -1 \neq 0), so that's 2 independent eigenvectors out of the 2 needed — continue to Step 4.

    • an n\times n matrix has n independent eigenvectors total — continue to Step 4.
    • fewer than n independent eigenvectors — stop; A is not diagonalizable.

    Why: P needs a full set of n independent columns to be invertible, and A=PDP^{-1} is only possible when such a full eigenbasis exists.

  4. 4

    Put the eigenvectors into the columns of P, and put each eigenvector's matching eigenvalue into the same-position diagonal entry of D.

    Example

    P = \begin{bmatrix} 1 & 2 \\ -1 & -3 \end{bmatrix}, \qquad D = \begin{bmatrix} 5 & 0 \\ 0 & 4 \end{bmatrix}

    Column 1 of P (the eigenvector for \lambda=5) lines up with D's first diagonal entry, 5; column 2 (for \lambda=4) lines up with D's second entry, 4.

    Why: Av_i=\lambda_iv_i has to hold column by column, so the order eigenvectors go into P has to match the order their eigenvalues go into D exactly.

  5. 5

    Compute P^{-1}, then confirm that multiplying PDP^{-1} back out reproduces A.

    Example

    \det P = (1)(-3)-(2)(-1) = -1, so P^{-1} = \dfrac{1}{-1}\begin{bmatrix} -3 & -2 \\ 1 & 1 \end{bmatrix} = \begin{bmatrix} 3 & 2 \\ -1 & -1 \end{bmatrix}. Then PD = \begin{bmatrix} 5 & 8 \\ -5 & -12 \end{bmatrix}, \qquad PDP^{-1} = \begin{bmatrix} 5 & 8 \\ -5 & -12 \end{bmatrix}\begin{bmatrix} 3 & 2 \\ -1 & -1 \end{bmatrix} = \begin{bmatrix} 7 & 2 \\ -3 & 2 \end{bmatrix} = A \ \checkmark

    Why: this checks the whole construction against the actual definition of diagonalizable, rather than trusting the eigenvalue and eigenvector computations alone.

Common mistakes

  • Writing A=P^{-1}DP instead of A=PDP^{-1}.
  • Putting an eigenvector into a column of P that doesn't line up with its own eigenvalue's position in D.
  • Finding an eigenvalue but never actually solving for its eigenvector.
  • Assuming every square matrix is diagonalizable, and skipping the independent-eigenvector count entirely.