---
title: Diagonalization
module: Eigenvalues and Eigenvectors
moduleNumber: 5
lessonNumber: 3
order: 503
summary: >
  A matrix is diagonalizable when it factors as A equals P D P inverse with D
  diagonal, which happens exactly when it has n linearly independent
  eigenvectors. The factorization computes matrix powers cheaply, distinct
  eigenvalues guarantee it, and a repeated eigenvalue permits it only when its
  eigenspace dimension equals its multiplicity.
topics: [Eigenvalues and Eigenvectors]
sources:
  - book: Lay
    ref: "§5.3 Diagonalization"
---

For many matrices $A$, the eigenvalues and eigenvectors assemble into a
factorization

$$
A = P D P^{-1},
$$

with $D$ diagonal. When this is possible, questions that are hard for $A$ become easy
for $D$. The clearest example is computing powers.

## Matrix powers from the factorization

Powers of a diagonal matrix are computed entrywise. If
$D = \begin{bmatrix} 5 & 0 \\ 0 & 3 \end{bmatrix}$, then
$D^k = \begin{bmatrix} 5^k & 0 \\ 0 & 3^k \end{bmatrix}$. When $A = P D P^{-1}$, the
inner factors telescope:

$$
A^2 = (P D P^{-1})(P D P^{-1}) = P D (P^{-1} P) D P^{-1} = P D^2 P^{-1},
$$

and by induction $A^k = P D^k P^{-1}$ for every $k \geq 1$. Computing a power of $A$
takes one diagonal power plus two matrix products, no matter how large $k$ is.

$$
% caption: The factorization $A = P D P^{-1}$ turns $A^k$ into $P D^k P^{-1}$; the
% only work that scales with $k$ is raising diagonal entries to the $k$th power.
\begin{tikzpicture}[>=stealth, font=\footnotesize,
  b/.style={draw, minimum width=13mm, minimum height=11mm, align=center}]
  \definecolor{acc}{HTML}{4A6FA5}
  \node[b] (P1) at (0,0) {$P$};
  \node[b, draw=acc, text=acc, thick] (D) at (1.6,0) {$D^k$};
  \node[b] (P2) at (3.2,0) {$P^{-1}$};
  \node at (-1.4,0) {$A^k \; = $};
  \draw[acc, thick] (D.north) ++(0,0.15) -- ++(0,0.5) node[above, acc] {entrywise $k$th powers};
\end{tikzpicture}
$$

> **Worked example.** Find a formula for $A^k$, given
> $A = \begin{bmatrix} 7 & 2 \\ -4 & 1 \end{bmatrix} = P D P^{-1}$ with
> $P = \begin{bmatrix} 1 & 1 \\ -1 & -2 \end{bmatrix}$ and
> $D = \begin{bmatrix} 5 & 0 \\ 0 & 3 \end{bmatrix}$.
>
> The inverse of $P$ is $P^{-1} = \begin{bmatrix} 2 & 1 \\ -1 & -1 \end{bmatrix}$, so
> $$
> A^k = P \begin{bmatrix} 5^k & 0 \\ 0 & 3^k \end{bmatrix} P^{-1}
>     = \begin{bmatrix}
>       2 \cdot 5^k - 3^k & 5^k - 3^k \\
>       2 \cdot 3^k - 2 \cdot 5^k & 2 \cdot 3^k - 5^k
>       \end{bmatrix}.
> $$
> Every entry is a combination of $5^k$ and $3^k$; the cost of the formula does not
> grow with $k$.

## The Diagonalization Theorem

> **Definition (Diagonalizable).** A square matrix $A$ is **diagonalizable** if it is
> similar to a diagonal matrix, that is, if $A = P D P^{-1}$ for some invertible $P$
> and some diagonal $D$.

> **Theorem (The Diagonalization Theorem).** An $n \times n$ matrix $A$ is
> diagonalizable if and only if $A$ has $n$ linearly independent eigenvectors.
> Moreover, $A = P D P^{-1}$ with $D$ diagonal holds if and only if the columns of $P$
> are $n$ independent eigenvectors of $A$, in which case the diagonal entries of $D$
> are the corresponding eigenvalues. Equivalently, $A$ is diagonalizable precisely
> when $\mathbb{R}^n$ has a basis of eigenvectors of $A$, an **eigenvector basis**.

> **Proof.** Let $P = [\,v_1 \; \cdots \; v_n\,]$ have columns $v_i$, and let $D$ be
> diagonal with entries $\lambda_1, \dots, \lambda_n$. Direct computation gives
>
> $$
> AP = [\,Av_1 \; \cdots \; Av_n\,], \qquad
> PD = [\,\lambda_1 v_1 \; \cdots \; \lambda_n v_n\,].
> $$
>
> If $A = P D P^{-1}$ then $AP = PD$, so column by column $Av_i = \lambda_i v_i$: each
> $v_i$ is an eigenvector, and since $P$ is invertible these columns are independent.
> Conversely, if the $v_i$ are $n$ independent eigenvectors, then $AP = PD$ holds and
> $P$ is invertible, so $A = P D P^{-1}$. $\blacksquare$

The proof also gives the procedure. Diagonalizing an $n \times n$ matrix has four steps.

```algorithm
caption: $\textsc{Diagonalize}(A)$ — factor $A = P D P^{-1}$ if possible
find the eigenvalues of A from the characteristic equation
for each distinct eigenvalue L do
  compute a basis for the eigenspace Nul(A - L I)
collect all eigenvectors found into columns v_1, ..., v_m
if m < n then
  return "not diagonalizable"   // too few independent eigenvectors
P <- [ v_1 ... v_n ]            // eigenvectors as columns
D <- diag(L_1, ..., L_n)        // matching eigenvalues, same order as P
return (P, D)
```

The order of the columns of $P$ is free, but the diagonal of $D$ must use the same
order: the $i$th diagonal entry is the eigenvalue of the $i$th column of $P$.

## Diagonalizing a matrix with a repeated eigenvalue

> **Worked example.** Diagonalize
> $$
> A = \begin{bmatrix} 1 & 3 & 3 \\ -3 & -5 & -3 \\ 3 & 3 & 1 \end{bmatrix}.
> $$
>
> The characteristic equation factors as
> $-\lambda^3 - 3\lambda^2 + 4 = -(\lambda - 1)(\lambda + 2)^2 = 0$, so the eigenvalues
> are $\lambda = 1$ and $\lambda = -2$ (multiplicity $2$). Bases for the eigenspaces are
> $$
> \lambda = 1: \; v_1 = \begin{bmatrix} 1 \\ -1 \\ 1 \end{bmatrix},
> \qquad
> \lambda = -2: \; v_2 = \begin{bmatrix} -1 \\ 1 \\ 0 \end{bmatrix},
> \; v_3 = \begin{bmatrix} -1 \\ 0 \\ 1 \end{bmatrix}.
> $$
> The set $\{v_1, v_2, v_3\}$ is independent, so
> $$
> P = \begin{bmatrix} 1 & -1 & -1 \\ -1 & 1 & 0 \\ 1 & 0 & 1 \end{bmatrix},
> \qquad
> D = \begin{bmatrix} 1 & 0 & 0 \\ 0 & -2 & 0 \\ 0 & 0 & -2 \end{bmatrix}.
> $$
> To check the work without inverting $P$, verify $AP = PD$; both sides equal
> $\begin{bmatrix} 1 & 2 & 2 \\ -1 & -2 & 0 \\ 1 & 0 & -2 \end{bmatrix}$.

The repeated eigenvalue $-2$ still gave a two-dimensional eigenspace, so three
independent eigenvectors were available. That does not always happen.

$$
% caption: Diagonalization aligns the standard action of $A$ (mixing coordinates)
% with a pure axiswise scaling $D$ once the eigenvector basis is used.
\begin{tikzpicture}[>=stealth, scale=0.8, font=\footnotesize]
  \definecolor{acc}{HTML}{4A6FA5}
  % standard grid, sheared action
  \draw[black] (-0.2,-0.2) grid (2.4,2.4);
  \draw[->, black, thick] (0,0) -- (2,0);
  \draw[->, black, thick] (0,0) -- (0,2);
  \node[black] at (1.1,-0.7) {standard basis: $A$ mixes};
  % arrow
  \draw[->, acc, very thick] (3.0,1.1) -- (4.2,1.1) node[midway, above, acc] {eigenbasis};
  \begin{scope}[xshift=5cm]
    \draw[acc!25] (-0.2,-0.2) grid (2.4,2.4);
    \draw[->, acc, thick] (0,0) -- (2,0) node[right] {scale};
    \draw[->, acc, thick] (0,0) -- (0,2) node[above] {scale};
    \node[black] at (1.1,-0.7) {eigenbasis: $D$ scales axes};
  \end{scope}
\end{tikzpicture}
$$

## A defective matrix

Diagonalizability is not automatic.

> **Worked example.** Determine whether
> $$
> A = \begin{bmatrix} 2 & 4 & 3 \\ -4 & -6 & -3 \\ 3 & 3 & 1 \end{bmatrix}
> $$
> is diagonalizable.
>
> The characteristic polynomial is again $-(\lambda - 1)(\lambda + 2)^2$, but now each
> eigenspace is only one-dimensional:
> $$
> \lambda = 1: \; v_1 = \begin{bmatrix} 1 \\ -1 \\ 1 \end{bmatrix},
> \qquad
> \lambda = -2: \; v_2 = \begin{bmatrix} -1 \\ 1 \\ 0 \end{bmatrix}.
> $$
> Every eigenvector is a multiple of $v_1$ or $v_2$, so there are at most two
> independent eigenvectors, not enough for a basis of $\mathbb{R}^3$. By the
> diagonalization theorem, $A$ is not diagonalizable.

A matrix that lacks a full set of independent eigenvectors is called **defective**.

> **Definition (Defective matrix).** A square matrix is **defective** if some
> eigenvalue has an eigenspace whose dimension (its **geometric multiplicity**) is
> strictly less than its algebraic multiplicity. A defective matrix is not
> diagonalizable.

## Sufficient and exact conditions

Distinct eigenvalues guarantee diagonalizability, because
[eigenvectors for distinct eigenvalues are independent](/linear-algebra/eigenvalues/eigenvectors-and-eigenvalues).

> **Theorem (Distinct eigenvalues imply diagonalizability).** An $n \times n$ matrix with $n$ distinct eigenvalues is
> diagonalizable.

This is sufficient but not necessary: the first $3 \times 3$ example above is
diagonalizable with only two distinct eigenvalues. The sharp criterion handles repeated
eigenvalues by comparing dimensions.

> **Theorem (Repeated eigenvalues).** Let $A$ be $n \times n$ with distinct
> eigenvalues $\lambda_1, \dots, \lambda_p$.
> - For each $k$, the dimension of the eigenspace for $\lambda_k$ is at most the
>   multiplicity of $\lambda_k$.
> - $A$ is diagonalizable if and only if the eigenspace dimensions sum to $n$, which
>   happens exactly when (i) the characteristic polynomial factors completely into
>   linear factors and (ii) the eigenspace dimension equals the multiplicity for each
>   $\lambda_k$.
> - If $A$ is diagonalizable, bases of the individual eigenspaces, taken together,
>   form an eigenvector basis of $\mathbb{R}^n$.

$$
% caption: Diagonalizability compares two multiplicities per eigenvalue; the matrix
% is diagonalizable only when geometric equals algebraic for every eigenvalue.
\begin{tikzpicture}[>=stealth, font=\footnotesize]
  \definecolor{acc}{HTML}{4A6FA5}
  \definecolor{red}{HTML}{B0413E}
  % diagonalizable case
  \node[align=center] at (0,2.2) {diagonalizable};
  \draw[acc, thick, fill=acc!12] (-1.4,1.2) rectangle (-0.4,1.9);
  \node[acc] at (-0.9,1.55) {2};
  \draw[acc, thick, fill=acc!12] (0.4,1.2) rectangle (1.4,1.9);
  \node[acc] at (0.9,1.55) {2};
  \node[black, anchor=east] at (-1.6,1.55) {geom};
  \draw[black, thick] (-1.4,0.3) rectangle (-0.4,1.0);
  \node at (-0.9,0.65) {2};
  \draw[black, thick] (0.4,0.3) rectangle (1.4,1.0);
  \node at (0.9,0.65) {2};
  \node[black, anchor=east] at (-1.6,0.65) {alg};
  % defective case
  \begin{scope}[xshift=5.4cm]
    \node[align=center] at (0,2.2) {defective};
    \draw[red, thick, fill=red!10] (-1.4,1.2) rectangle (-0.4,1.9);
    \node[red] at (-0.9,1.55) {1};
    \draw[red, thick, fill=red!10] (0.4,1.55) rectangle (1.4,1.9);
    \node[red] at (0.9,1.72) {1};
    \node[black, anchor=east] at (-1.6,1.55) {geom};
    \draw[black, thick] (-1.4,0.3) rectangle (-0.4,1.0);
    \node at (-0.9,0.65) {1};
    \draw[black, thick] (0.4,0.3) rectangle (1.4,1.0);
    \node at (0.9,0.65) {2};
    \node[black, anchor=east] at (-1.6,0.65) {alg};
    \node[red, anchor=north] at (0.9,0.2) {geom $<$ alg};
  \end{scope}
\end{tikzpicture}
$$

For a triangular matrix the eigenvalues are read off the diagonal, so diagonalizability
of, say,

$$
A = \begin{bmatrix} 5 & -8 & 1 \\ 0 & 0 & 7 \\ 0 & 0 & -2 \end{bmatrix}
$$

is settled immediately: three distinct diagonal entries $5, 0, -2$, hence three distinct
eigenvalues, hence diagonalizable by the distinct-eigenvalues criterion.

## The two multiplicities

| Quantity | Definition | Bound |
| --- | --- | --- |
| Algebraic multiplicity of $\lambda$ | its multiplicity as a root of $\det(A - \lambda I)$ | between $1$ and $n$ |
| Geometric multiplicity of $\lambda$ | $\dim \operatorname{Nul}(A - \lambda I)$ | between $1$ and the algebraic multiplicity |
| Diagonalizable? | yes iff geometric $=$ algebraic for every eigenvalue | and multiplicities sum to $n$ |

Read as a statement about maps, $A = P D P^{-1}$ says that $x \mapsto Ax$ is a pure
scaling along the axes of the eigenvector basis. The precise version for transformations
between abstract vector spaces is
[eigenvectors and linear transformations](/linear-algebra/eigenvalues/eigenvectors-and-linear-transformations).[^lay53]

[^lay53]: **Lay**, _Linear Algebra and Its Applications_, 5th ed., §5.3 — Diagonalization: the factorization $A = P D P^{-1}$ and its use for powers, Theorem 5 (the Diagonalization Theorem), Theorem 6 (distinct eigenvalues), and Theorem 7 (eigenspace dimensions versus multiplicities).
