---
title: Diagonalization of Symmetric Matrices
module: Symmetric Matrices, Quadratic Forms, and the SVD
moduleNumber: 7
lessonNumber: 1
order: 701
summary: >
  A symmetric matrix is one that equals its own transpose. Every such matrix can
  be diagonalized by an orthogonal change of basis, A = PDPᵀ, with real
  eigenvalues and perpendicular eigenvectors. This is the Spectral Theorem, and
  it rewrites A as a weighted sum of rank-one projections onto its eigenvectors.
topics: [Symmetric Matrices, Quadratic Forms, and the SVD]
sources:
  - book: Lay
    ref: "Ch. 7 — Symmetric Matrices and Quadratic Forms; §7.1 Diagonalization of Symmetric Matrices"
draft: false
---

[Diagonalization](/linear-algebra/eigenvalues/diagonalization) factors a matrix
as $A = PDP^{-1}$ when it has enough independent eigenvectors. For a general
matrix that condition can fail, and even when it holds the eigenvector matrix
$P$ is usually not convenient: its inverse must be computed, and its columns
sit at arbitrary angles. Symmetric matrices avoid both problems at once. They
are always diagonalizable, their eigenvectors can always be chosen mutually
perpendicular, and the change-of-basis matrix is orthogonal, so its inverse is
just its transpose.

> **Definition (Symmetric matrix).** A matrix $A$ with $A^\top = A$. Such a
> matrix is necessarily square, and its off-diagonal entries occur in mirrored
> pairs: $a_{ij} = a_{ji}$.

For example, $\begin{bmatrix} 1 & 0 \\ 0 & -3 \end{bmatrix}$ and
$\begin{bmatrix} 0 & -1 & 5 \\ -1 & 3 & 0 \\ 5 & 0 & -2 \end{bmatrix}$
are symmetric; a matrix with $a_{12}=4$ but $a_{21}=6$ is not.

## Eigenvectors of a symmetric matrix are orthogonal

Eigenvectors belonging to different eigenvalues are automatically
perpendicular. Nothing like this holds for a general matrix.

> **Theorem (Orthogonal eigenspaces).** If $A$ is symmetric, then any two
> eigenvectors from different eigenspaces are orthogonal.

The proof turns the symmetry $A^\top = A$ into a statement about the dot
product. Let $v_1, v_2$ be eigenvectors for distinct
eigenvalues $\lambda_1, \lambda_2$. Using $u^\top w = u \cdot w$ and moving $A$
across the product with its transpose,

$$
\lambda_1 (v_1 \cdot v_2) = (\lambda_1 v_1)^\top v_2 = (A v_1)^\top v_2
= v_1^\top A^\top v_2 = v_1^\top A v_2 = v_1^\top(\lambda_2 v_2)
= \lambda_2 (v_1 \cdot v_2).
$$

The middle equality $A^\top = A$ is the only place symmetry enters. Rearranging,
$(\lambda_1 - \lambda_2)(v_1 \cdot v_2) = 0$, and since $\lambda_1 \neq \lambda_2$
the eigenvalues cancel, forcing $v_1 \cdot v_2 = 0$. For a general matrix,
distinct eigenvalues give only independent eigenspaces; symmetry makes them
orthogonal.

$$
% caption: A symmetric matrix stretches space along perpendicular axes: the
% unit circle maps to an ellipse whose axes lie along the orthogonal
% eigenvectors, scaled by the eigenvalues.
\begin{tikzpicture}[scale=1.0, >=stealth, font=\footnotesize]
  \definecolor{acc}{HTML}{4A6FA5}
  % unit circle (left)
  \draw[thick] (-1.4,0) circle (0.9);
  \draw[->, acc, very thick] (-1.4,0) -- (-0.5,0) node[below right, black] {$v_1$};
  \draw[->, acc, very thick] (-1.4,0) -- (-1.4,0.9) node[above, black] {$v_2$};
  \node[black] at (-1.4,-1.5) {unit circle};
  % arrow
  \draw[->, black, thick] (0.3,0) -- (1.5,0) node[midway, above] {$A$};
  % ellipse (right)
  \draw[thick] (4.0,0) ellipse (2.0 and 0.7);
  \draw[->, acc, very thick] (4.0,0) -- (6.0,0) node[below right, black] {$3\,v_1$};
  \draw[->, acc, very thick] (4.0,0) -- (4.0,0.7) node[above, black] {$v_2$};
  \node[black] at (4.0,-1.9) {stretched ellipse};
\end{tikzpicture}
$$

## Orthogonal diagonalizability

An orthogonal matrix $P$ has orthonormal columns, which is equivalent to
$P^\top P = I$, so its inverse is $P^{-1} = P^\top$.[^orth] When the eigenvector
matrix can be chosen orthogonal, diagonalization needs no inverse.

> **Definition (Orthogonally diagonalizable).** An $n \times n$ matrix $A$ is
> orthogonally diagonalizable if there is an orthogonal matrix $P$ (so
> $P^{-1}=P^\top$) and a diagonal matrix $D$ with
> $$
> A = PDP^\top = PDP^{-1}.
> $$
> The columns of $P$ are $n$ orthonormal eigenvectors of $A$, and the diagonal
> of $D$ holds the matching eigenvalues.

The condition does more than simplify computation; it characterizes
symmetry. One direction is immediate: if $A = PDP^\top$, then

$$
A^\top = (PDP^\top)^\top = P^{\top\top} D^\top P^\top = PDP^\top = A,
$$

using $D^\top = D$ for a diagonal matrix. So an orthogonally diagonalizable
matrix must be symmetric. The converse is the harder and more useful statement.

> **Theorem (Orthogonal diagonalizability characterizes symmetry).** An $n \times n$ matrix $A$ is orthogonally diagonalizable if
> and only if $A$ is symmetric.

For a general matrix, deciding diagonalizability requires inspecting eigenvalue
multiplicities case by case. For symmetric matrices the question is settled in
advance by a glance at the entries.

## The Spectral Theorem

The orthogonal-diagonalizability theorem is one part of a larger statement. The set of eigenvalues of $A$ is
its **spectrum**, and the Spectral Theorem collects four properties of a real
symmetric matrix.

> **Theorem (Spectral Theorem for symmetric matrices).** An $n \times n$
> symmetric matrix $A$ has these properties:
>
> - **(a) Real spectrum.** $A$ has $n$ real eigenvalues, counted with
>   multiplicity.
> - **(b) Full eigenspaces.** The dimension of the eigenspace for each
>   eigenvalue $\lambda$ equals the multiplicity of $\lambda$ as a root of the
>   characteristic equation.
> - **(c) Orthogonality.** Eigenspaces for different eigenvalues are mutually
>   orthogonal.
> - **(d) Diagonalizability.** $A$ is orthogonally diagonalizable.

Property (a) says the characteristic polynomial of a real symmetric matrix has
no complex roots, so the spiral dynamics of
[complex eigenvalues](/linear-algebra/eigenvalues/complex-eigenvalues) never
occur here. Property (b) rules out the defect that blocks diagonalization in the
general case: a symmetric matrix never runs short of eigenvectors. Property (c)
is the orthogonal-eigenspaces theorem. Together they guarantee (d): assemble an orthonormal basis inside
each eigenspace, and because eigenspaces are orthogonal, the pooled set is an
orthonormal eigenvector basis for $\mathbb{R}^n$.

$$
% caption: Orthogonal diagonalization sends A to a pure scaling D in the
% eigenvector coordinates: read into the eigenbasis by Pᵀ, scale each axis by
% its eigenvalue, then read back out by P.
\begin{tikzpicture}[scale=1.0, >=stealth, font=\footnotesize,
  blk/.style={draw, minimum width=15mm, minimum height=11mm, align=center}]
  \definecolor{acc}{HTML}{4A6FA5}
  \node[blk, draw=acc, text=acc, thick] (A) at (0,0) {$A$};
  \node at (1.2,0) {$=$};
  \node[blk] (P) at (2.6,0) {$P$};
  \node[blk] (D) at (4.4,0) {$D$};
  \node[blk] (PT) at (6.2,0) {$P^T$};
  \node[black, align=center] at (2.6,-1.2) {orthonormal\\eigenvectors};
  \node[black, align=center] at (4.4,-1.2) {eigenvalues\\on diagonal};
  \node[black, align=center] at (6.2,-1.2) {read into\\eigenbasis};
  \draw[black] (P.north) ++(0,0.2) -- ++(0,0.35);
  \draw[black] (PT.north) ++(0,0.2) -- ++(0,0.35);
  \draw[black] (2.35,0.72) -- (6.45,0.72) node[midway, above, black] {orthogonal: $P^T P = I$};
\end{tikzpicture}
$$

### Distinct eigenvalues

When the eigenvalues are distinct, the eigenvectors are automatically orthogonal
and only normalization remains.

> **Worked example.** Orthogonally diagonalize
> $$
> A = \begin{bmatrix} 6 & -2 & -1 \\ -2 & 6 & -1 \\ -1 & -1 & 5 \end{bmatrix}.
> $$
> The characteristic equation factors as
> $-\lambda^3 + 17\lambda^2 - 90\lambda + 144 = -(\lambda-8)(\lambda-6)(\lambda-3)$,
> giving eigenvalues $8, 6, 3$. Bases for the three eigenspaces are
> $$
> \lambda = 8: \; v_1 = \begin{bmatrix} -1 \\ 1 \\ 0 \end{bmatrix}, \quad
> \lambda = 6: \; v_2 = \begin{bmatrix} -1 \\ -1 \\ 2 \end{bmatrix}, \quad
> \lambda = 3: \; v_3 = \begin{bmatrix} 1 \\ 1 \\ 1 \end{bmatrix}.
> $$
> The dot products $v_1 \cdot v_2 = 1 - 1 + 0 = 0$ and
> $v_1 \cdot v_3 = v_2 \cdot v_3 = 0$ confirm that the set is already orthogonal,
> as the orthogonal-eigenspaces theorem predicts. Normalizing each vector to unit length and collecting
> the results as columns,
> $$
> P = \begin{bmatrix}
> -1/\sqrt{2} & -1/\sqrt{6} & 1/\sqrt{3} \\
> 1/\sqrt{2} & -1/\sqrt{6} & 1/\sqrt{3} \\
> 0 & 2/\sqrt{6} & 1/\sqrt{3}
> \end{bmatrix},
> \qquad
> D = \begin{bmatrix} 8 & 0 & 0 \\ 0 & 6 & 0 \\ 0 & 0 & 3 \end{bmatrix},
> $$
> and $A = PDP^\top$, with $P^{-1} = P^\top$ obtained by transposition instead of
> inversion.

### Repeated eigenvalues

When an eigenvalue is repeated, the eigenvectors returned by row reduction span
the right space but need not be perpendicular to one another.
[Gram–Schmidt](/linear-algebra/orthogonality-least-squares/gram-schmidt-and-qr)
applied inside the eigenspace repairs this.

> **Worked example.** Orthogonally diagonalize
> $$
> A = \begin{bmatrix} 3 & -2 & 4 \\ -2 & 6 & 2 \\ 4 & 2 & 3 \end{bmatrix},
> \qquad
> 0 = -\lambda^3 + 12\lambda^2 - 21\lambda - 98 = -(\lambda-7)^2(\lambda+2).
> $$
> The eigenvalue $7$ has multiplicity two. Row reduction of $A - 7I$ produces two
> independent eigenvectors,
> $$
> \lambda = 7: \; v_1 = \begin{bmatrix} 1 \\ 0 \\ 1 \end{bmatrix},
> \; v_2 = \begin{bmatrix} -1/2 \\ 1 \\ 0 \end{bmatrix},
> \qquad
> \lambda = -2: \; v_3 = \begin{bmatrix} -1 \\ -1/2 \\ 1 \end{bmatrix}.
> $$
> Here $v_1 \cdot v_2 = -\tfrac12 \neq 0$, so the two vectors in the $\lambda=7$
> eigenspace are not orthogonal. Subtracting the projection of $v_2$ onto $v_1$,
> $$
> z_2 = v_2 - \frac{v_2 \cdot v_1}{v_1 \cdot v_1}\, v_1
> = \begin{bmatrix} -1/2 \\ 1 \\ 0 \end{bmatrix}
> - \frac{-1/2}{2} \begin{bmatrix} 1 \\ 0 \\ 1 \end{bmatrix}
> = \begin{bmatrix} -1/4 \\ 1 \\ 1/4 \end{bmatrix}.
> $$
> Since $z_2$ is a linear combination of two eigenvectors for $\lambda = 7$, it is
> itself an eigenvector for $\lambda = 7$, and by construction $z_2 \perp v_1$. So
> $\{v_1, z_2\}$ is an orthogonal basis for the two-dimensional eigenspace. The
> eigenvector $v_3$ for the distinct eigenvalue $-2$ is automatically orthogonal
> to both by the orthogonal-eigenspaces theorem. Normalizing all three gives an orthonormal eigenvector
> basis, and $A = PDP^\top$ with $D = \operatorname{diag}(7,7,-2)$.

$$
% caption: Inside a repeated eigenspace the raw eigenvectors need not be
% perpendicular; Gram–Schmidt subtracts the projection of v₂ onto v₁ to produce
% z₂ ⟂ v₁ spanning the same plane.
\begin{tikzpicture}[scale=1.0, >=stealth, font=\footnotesize]
  \definecolor{acc}{HTML}{4A6FA5}
  \draw[black, fill=acc!7] (-0.4,-0.4) -- (5.2,-0.4) -- (6.2,1.9) -- (0.6,1.9) -- cycle;
  \node[black] at (4.9,1.55) {eigenspace for $7$};
  \coordinate (O) at (1.2,0.1);
  \draw[->, acc, very thick] (O) -- ++(3.0,0);
  \node[black] at (4.55,0.5) {$v_1$};
  \draw[->, black, thick] (O) -- ++(1.6,1.2);
  \node[black] at (3.2,1.5) {$v_2$};
  % drop perpendicular from the v2 tip onto the v1 line
  \coordinate (F) at ($(O)+(1.6,0)$);
  \draw[black, dashed] ($(O)+(1.6,1.2)$) -- (F);
  % z2 = perpendicular component, drawn from the origin
  \draw[->, acc, very thick] (O) -- ++(0,1.2);
  \node[black] at (0.85,1.15) {$z_2$};
  \node[black] at (2.7,-0.85) {drop $v_2$ onto $v_1$};
\end{tikzpicture}
$$

## Spectral decomposition

Writing $A = PDP^\top$ and expanding the product columnwise expresses $A$ as a
sum of one-term contributions, one per eigenpair. Let the columns of $P$ be the
orthonormal eigenvectors $u_1, \dots, u_n$ and the diagonal of $D$ the
eigenvalues $\lambda_1, \dots, \lambda_n$. The column–row rule for a product
gives

$$
A = PDP^\top = \begin{bmatrix} u_1 & \cdots & u_n \end{bmatrix}
\begin{bmatrix} \lambda_1 & & \\ & \ddots & \\ & & \lambda_n \end{bmatrix}
\begin{bmatrix} u_1^\top \\ \vdots \\ u_n^\top \end{bmatrix}
= \lambda_1 u_1 u_1^\top + \lambda_2 u_2 u_2^\top + \cdots + \lambda_n u_n u_n^\top.
$$

> **Definition (Spectral decomposition).** The representation
> $A = \sum_{i=1}^n \lambda_i\, u_i u_i^\top$ of a symmetric matrix as a
> weighted sum of the rank-one matrices $u_i u_i^\top$, one for each orthonormal
> eigenvector, weighted by the corresponding eigenvalue.

Each term $u_i u_i^\top$ is an $n \times n$ matrix of **rank one**: every column
is a scalar multiple of $u_i$. More is true. The matrix $u_i u_i^\top$ is the
[orthogonal projection](/linear-algebra/orthogonality-least-squares/orthogonal-sets-and-projections)
onto the line spanned by $u_i$, because for any $x$,

$$
(u_i u_i^\top) x = u_i (u_i^\top x) = (u_i \cdot x)\, u_i,
$$

which reproduces the projection formula for a unit vector. So the spectral
decomposition resolves $A$ into projections onto its eigenvector axes, each
scaled by its eigenvalue. Applying $A$ to a vector projects onto each axis,
rescales by $\lambda_i$, and sums.

$$
% caption: Spectral decomposition stacks A out of rank-one projection layers:
% each uᵢuᵢᵀ projects onto one eigenvector axis, scaled by its eigenvalue λᵢ.
\begin{tikzpicture}[scale=1.0, >=stealth, font=\footnotesize,
  lyr/.style={draw, minimum width=17mm, minimum height=13mm, align=center}]
  \definecolor{acc}{HTML}{4A6FA5}
  \node[lyr, draw=acc, text=acc, thick] (A) at (0,0) {$A$};
  \node at (1.3,0) {$=$};
  \node[lyr, fill=acc!12] (t1) at (2.7,0) {$8\, u_1 u_1^T$};
  \node at (4.0,0) {$+$};
  \node[lyr, fill=acc!8] (t2) at (5.3,0) {$3\, u_2 u_2^T$};
  \node[black, align=center] at (2.7,-1.15) {rank-one\\projection};
  \node[black, align=center] at (5.3,-1.15) {rank-one\\projection};
\end{tikzpicture}
$$

> **Worked example.** Build the spectral decomposition of
> $$
> A = \begin{bmatrix} 7 & 2 \\ 2 & 4 \end{bmatrix}
> = \begin{bmatrix} 2/\sqrt5 & -1/\sqrt5 \\ 1/\sqrt5 & 2/\sqrt5 \end{bmatrix}
> \begin{bmatrix} 8 & 0 \\ 0 & 3 \end{bmatrix}
> \begin{bmatrix} 2/\sqrt5 & 1/\sqrt5 \\ -1/\sqrt5 & 2/\sqrt5 \end{bmatrix}.
> $$
> With $u_1 = \tfrac{1}{\sqrt5}(2,1)$ and $u_2 = \tfrac{1}{\sqrt5}(-1,2)$, the
> decomposition is $A = 8 u_1 u_1^\top + 3 u_2 u_2^\top$. The two projection
> matrices are
> $$
> 8\, u_1 u_1^\top = 8 \cdot \frac15 \begin{bmatrix} 4 & 2 \\ 2 & 1 \end{bmatrix}
> = \begin{bmatrix} 32/5 & 16/5 \\ 16/5 & 8/5 \end{bmatrix},
> \qquad
> 3\, u_2 u_2^\top = 3 \cdot \frac15 \begin{bmatrix} 1 & -2 \\ -2 & 4 \end{bmatrix}
> = \begin{bmatrix} 3/5 & -6/5 \\ -6/5 & 12/5 \end{bmatrix},
> $$
> and their sum is $\begin{bmatrix} 35/5 & 10/5 \\ 10/5 & 20/5 \end{bmatrix}
> = \begin{bmatrix} 7 & 2 \\ 2 & 4 \end{bmatrix} = A$.

The three ways to hold a symmetric matrix each expose a different fact about it.

| Form | Expression | What it exposes |
| --- | --- | --- |
| Entries | $A$ with $a_{ij}=a_{ji}$ | symmetry, at a glance |
| Orthogonal diagonalization | $A = PDP^\top$ | eigenvalues and perpendicular axes |
| Spectral decomposition | $A = \sum_i \lambda_i u_i u_i^\top$ | rank-one projection structure |

## Orthogonality and computation

The eigenvalues of a symmetric matrix are computed by applying a sequence of
similarity transformations built from orthogonal matrices, driving $A$ toward
diagonal form while its diagonal entries converge to the eigenvalues. Because
orthogonal matrices preserve lengths, rounding errors do not accumulate the way
they can under a general similarity, so the process is numerically stable. When
$A$ is symmetric the orthogonal factors multiply together into a single
orthogonal matrix whose columns are the eigenvectors. A nonsymmetric matrix has
no full orthogonal eigenvector set, so after its eigenvalues are found the
eigenvectors require separate, less stable work. The
[numerical eigenvalue](/linear-algebra/numerical-linear-algebra/numerical-eigenvalues-and-svd)
methods develop this computation in detail.

Two closure properties fall directly out of the theory. If $A$ is symmetric then
$A^2$ is symmetric, since $(A^2)^\top = (A^\top)^2 = A^2$; and if $A$ is
orthogonally diagonalizable then so is $A^2 = PD^2P^\top$, with the eigenvalues
squared and the same eigenvectors. The eigenvector axes are fixed by $A$; powers
of $A$ only rescale the stretch along them.

[^orth]: **Lay**, §6.2 — Orthogonal Sets: a square matrix with orthonormal
    columns satisfies $P^\top P = I$, hence $P^{-1} = P^\top$, and such a matrix
    preserves lengths and dot products.
