
# Eigenvalues & the Spectral Theorem

> Measurement outcomes *are* eigenvalues; the states you collapse into *are* eigenvectors. The
> spectral theorem — that observables can be diagonalized in an orthonormal eigenbasis — is the
> mathematical content of the measurement postulate, the reason phase estimation works, and the tool
> that lets us define functions of operators (like $e^{-iHt}$). This is the technical heart of
> Course 0.1.

## Learning Objectives

After this lesson you will be able to:

1. Compute eigenvalues/eigenvectors via the characteristic polynomial and diagonalize a matrix.
2. Define **normal** operators and state the **spectral theorem** for them.
3. Write an operator in its **spectral decomposition** $A = \sum_k \lambda_k P_k$.
4. Explain **degeneracy** and project onto eigenspaces.
5. Prove that operators are **simultaneously diagonalizable iff they commute**.

---

## Intuition

An **eigenvector** of $A$ is a special direction that $A$ merely stretches (by the **eigenvalue**),
without rotating it: $A|v\rangle = \lambda|v\rangle$. If you can find a full basis of eigenvectors, the
operator becomes trivial to understand — in that basis it's just "multiply coordinate $k$ by
$\lambda_k$," a diagonal matrix. The spectral theorem says the operators of physics (Hermitian
observables, unitary gates — all *normal*) always admit such an **orthonormal** eigenbasis. That's
why we can always think of an observable as "a set of outcomes $\lambda_k$ each attached to a
perpendicular measurement direction."

---

## Theory

### Eigenvalues and eigenvectors

For an operator $A$ on $\mathbb{C}^n$, a nonzero $|v\rangle$ is an **eigenvector** with **eigenvalue**
$\lambda\in\mathbb{C}$ if

$$
A|v\rangle = \lambda|v\rangle \;\Longleftrightarrow\; (A - \lambda I)|v\rangle = 0 .
$$

A nonzero solution exists iff $A-\lambda I$ is singular, i.e. iff $\lambda$ is a root of the
**characteristic polynomial**

$$
p_A(\lambda) = \det(A - \lambda I) = 0 .
$$

Over $\mathbb{C}$, $p_A$ has degree $n$ and (by the fundamental theorem of algebra) exactly $n$ roots
counted with multiplicity — *every* complex matrix has at least one eigenvalue. The **eigenspace** for
$\lambda$ is $\ker(A-\lambda I)$; its dimension is the **geometric multiplicity**, and $\lambda$ is
**degenerate** if that exceeds $1$.

### Diagonalization

$A$ is **diagonalizable** if there is a basis of eigenvectors. Stacking them as columns of $V$,

$$
A = V \Lambda V^{-1}, \qquad \Lambda = \operatorname{diag}(\lambda_1,\dots,\lambda_n).
$$

From this, $\operatorname{Tr}(A) = \sum_k \lambda_k$ and $\det(A) = \prod_k \lambda_k$ (eigenvalues are
the trace/determinant's "atoms"). Not every matrix is diagonalizable (e.g. $\begin{psmallmatrix}0&1\\0&0\end{psmallmatrix}$
is *defective*), but the operators we care about always are — because they are normal.

### Normal operators and the spectral theorem

$A$ is **normal** if it commutes with its adjoint:

$$
A^\dagger A = A A^\dagger .
$$

Hermitian ($A^\dagger=A$) and unitary ($A^\dagger = A^{-1}$) operators are both normal. The payoff:

> **Spectral theorem (finite-dimensional).** $A$ is normal **iff** it is **unitarily
> diagonalizable**: there exists an orthonormal eigenbasis $\{|v_k\rangle\}$ and eigenvalues
> $\lambda_k$ with
> $$ A = \sum_k \lambda_k\,|v_k\rangle\langle v_k| = U\Lambda U^\dagger, \quad U = \sum_k |v_k\rangle\langle e_k|\ \text{unitary}. $$

**Proof of the key direction (normal ⇒ orthonormal eigenbasis), by induction on $n$.** Every operator
on $\mathbb{C}^n$ has an eigenvalue $\lambda_1$ with a unit eigenvector $|v_1\rangle$ (root of $p_A$).
Consider $W = \{|w\rangle : \langle v_1|w\rangle = 0\}$, the orthogonal complement of $|v_1\rangle$.
**Claim: $W$ is invariant under $A$.** First, normality gives that $|v_1\rangle$ is also an eigenvector
of $A^\dagger$ with eigenvalue $\overline{\lambda_1}$ (standard lemma: for normal $A$,
$\|(A-\lambda I)x\| = \|(A^\dagger - \overline\lambda I)x\|$, so they share eigenvectors). Then for
$|w\rangle\in W$: $\langle v_1|A w\rangle = \langle A^\dagger v_1|w\rangle = \lambda_1\langle v_1|w\rangle = 0$,
so $A|w\rangle\in W$. The restriction $A|_W$ is normal on the $(n-1)$-dimensional $W$; by induction it
has an orthonormal eigenbasis, which together with $|v_1\rangle$ gives one for all of $\mathbb{C}^n$. ∎

### Spectral decomposition and eigenprojectors

Grouping repeated eigenvalues, write the **distinct** eigenvalues $\lambda_k$ with orthogonal
projectors $P_k$ onto their eigenspaces:

$$
A = \sum_k \lambda_k P_k, \qquad P_k = \sum_{i:\,\lambda_i = \lambda_k}|v_i\rangle\langle v_i|,
\qquad P_k P_l = \delta_{kl}P_k,\quad \sum_k P_k = I .
$$

This is the form the measurement postulate uses (Term 1.3): outcome $\lambda_k$ occurs with
probability $\langle\psi|P_k|\psi\rangle$ and collapses the state to $P_k|\psi\rangle/\|P_k|\psi\rangle\|$.

### Functions of operators

The spectral decomposition lets us apply any function $f:\mathbb{C}\to\mathbb{C}$ to a normal operator:

$$
f(A) := \sum_k f(\lambda_k)\,P_k .
$$

In particular $e^{-iHt} = \sum_k e^{-i\lambda_k t}P_k$ — the engine of time evolution (Term 1.6) and
of building gates from Hamiltonians. We develop this fully in [0.1.6](06-special-operators.md).

### Simultaneous diagonalization

> **Theorem.** Two normal operators $A,B$ are simultaneously diagonalizable (share an orthonormal
> eigenbasis) **iff** $[A,B] = 0$.

**Proof (⇐, the useful direction).** If they share an eigenbasis $\{|v_k\rangle\}$ with $A|v_k\rangle =
a_k|v_k\rangle$, $B|v_k\rangle = b_k|v_k\rangle$, then $AB|v_k\rangle = a_k b_k|v_k\rangle = BA|v_k\rangle$
on a basis, so $AB = BA$. Conversely if $[A,B]=0$, $B$ preserves each eigenspace of $A$ (if $A|v\rangle
= a|v\rangle$ then $A(B|v\rangle) = BA|v\rangle = aB|v\rangle$, so $B|v\rangle$ is in the same eigenspace);
diagonalizing $B$ within each eigenspace of $A$ yields a common eigenbasis. ∎

Physically: **commuting observables are jointly measurable** with definite simultaneous values — the
formal counterpart of the commutator discussion in [0.1.4](04-linear-operators-matrices.md).

---

## Worked Examples

### Example 1 — Diagonalizing Pauli-$X$

Characteristic polynomial of $X = \begin{psmallmatrix}0&1\\1&0\end{psmallmatrix}$:
$\det(X-\lambda I) = \lambda^2 - 1 = 0 \Rightarrow \lambda = \pm 1$.
For $\lambda = +1$: $(X-I)|v\rangle = 0 \Rightarrow$ components equal $\Rightarrow |v_+\rangle =
\tfrac1{\sqrt2}(1,1)^T = |+\rangle$. For $\lambda = -1$: $|v_-\rangle = \tfrac1{\sqrt2}(1,-1)^T = |-\rangle$.
These are orthonormal (as the spectral theorem guarantees for the Hermitian $X$). Spectral
decomposition:

$$
X = (+1)|+\rangle\langle+| + (-1)|-\rangle\langle-| .
$$

Check trace $= 1 - 1 = 0$ ✓ and det $= (1)(-1) = -1$ ✓, matching [0.1.4](04-linear-operators-matrices.md).

### Example 2 — A degenerate operator and its eigenprojector

Let $A = \begin{psmallmatrix} 2 & 0 & 0\\ 0 & 2 & 0\\ 0 & 0 & 5\end{psmallmatrix}$. Eigenvalue $\lambda
= 2$ is **doubly degenerate** with eigenspace $\operatorname{span}\{|0\rangle,|1\rangle\}$, and
$\lambda = 5$ with eigenvector $|2\rangle$. The eigenprojectors are

$$
P_2 = |0\rangle\langle0| + |1\rangle\langle1| = \operatorname{diag}(1,1,0),\quad
P_5 = |2\rangle\langle2| = \operatorname{diag}(0,0,1),
$$

with $A = 2P_2 + 5P_5$, $P_2 + P_5 = I$, $P_2 P_5 = 0$. Note the eigenvectors *within* the degenerate
space are not unique — any orthonormal pair spanning it works — but the **projector** $P_2$ is unique.

---

## Hands-on (Python)

```python
import numpy as np

X = np.array([[0, 1], [1, 0]], dtype=complex)

# For Hermitian/normal matrices, use eigh: returns REAL, sorted eigenvalues and an
# ORTHONORMAL eigenbasis (columns of vecs). Reserve np.linalg.eig for general matrices.
vals, vecs = np.linalg.eigh(X)
print(vals)                       # [-1.  1.]
print(np.round(vecs, 3))          # columns are |->, |+>  (orthonormal)

# Verify diagonalization A = V Λ V†:
Lam = np.diag(vals)
print(np.allclose(vecs @ Lam @ vecs.conj().T, X))   # True

# Spectral decomposition A = Σ λ_k |v_k><v_k|:
A_rebuilt = sum(l * np.outer(vecs[:, k], vecs[:, k].conj())
                for k, l in enumerate(vals))
print(np.allclose(A_rebuilt, X))  # True
```

```python
# Functions of operators via the spectrum: build U = exp(-i X t) two ways and compare.
from scipy.linalg import expm

def f_of_operator(vals, vecs, f):
    return sum(f(l) * np.outer(vecs[:, k], vecs[:, k].conj())
               for k, l in enumerate(vals))

t = 0.7
U_spectral = f_of_operator(vals, vecs, lambda l: np.exp(-1j * l * t))
U_expm = expm(-1j * X * t)
print(np.allclose(U_spectral, U_expm))   # True — spectral calculus = matrix exponential
```

```python
# Commuting ⇒ simultaneously diagonalizable. Z and Z commute trivially; X and Z do NOT:
Z = np.array([[1, 0], [0, -1]], dtype=complex)
def comm(A, B): return A @ B - B @ A
print(np.allclose(comm(X, Z), 0))        # False: X,Z share no common eigenbasis
```

---

## Exercises

**E1 (easy).** Find the eigenvalues and orthonormal eigenvectors of $Z = \operatorname{diag}(1,-1)$ and
write its spectral decomposition.

<details><summary>Solution</summary>

Already diagonal: eigenvalues $+1$ (eigenvector $|0\rangle$) and $-1$ ($|1\rangle$). Spectral form
$Z = (+1)|0\rangle\langle0| + (-1)|1\rangle\langle1|$.
</details>

**E2 (easy).** Show that the eigenvalues of any **projector** $P = P^\dagger = P^2$ are $0$ or $1$.

<details><summary>Solution</summary>

If $P|v\rangle = \lambda|v\rangle$ then $P^2|v\rangle = \lambda^2|v\rangle$; but $P^2 = P$ gives
$\lambda^2 = \lambda$, so $\lambda\in\{0,1\}$. (Eigenvalue $1$: vectors in the subspace; $0$: its
orthogonal complement.)
</details>

**E3 (medium).** Prove that a Hermitian operator has **real** eigenvalues and that eigenvectors for
distinct eigenvalues are orthogonal.

<details><summary>Solution</summary>

Let $A=A^\dagger$, $A|v\rangle = \lambda|v\rangle$ with $\langle v|v\rangle = 1$. Then $\lambda =
\langle v|A|v\rangle = \overline{\langle v|A^\dagger|v\rangle} = \overline{\langle v|A|v\rangle} =
\overline\lambda$, so $\lambda\in\mathbb{R}$. For $A|v\rangle = a|v\rangle$, $A|w\rangle = b|w\rangle$
with $a\neq b$: $a\langle w|v\rangle = \langle w|A|v\rangle = \langle Aw|v\rangle = b\langle w|v\rangle$
(using $b$ real). So $(a-b)\langle w|v\rangle = 0 \Rightarrow \langle w|v\rangle = 0$. ∎
</details>

**E4 (medium).** Diagonalize the Hadamard $H = \tfrac1{\sqrt2}\begin{psmallmatrix}1&1\\1&-1\end{psmallmatrix}$.
What are its eigenvalues?

<details><summary>Solution</summary>

$\det(H-\lambda I) = (\tfrac1{\sqrt2}-\lambda)(-\tfrac1{\sqrt2}-\lambda) - \tfrac12 = \lambda^2 - 1 = 0$,
so $\lambda = \pm1$ (consistent with $H^2 = I$). $H$ is Hermitian and unitary, an involution; its
eigenvectors are the two fixed/anti-fixed directions of the reflection it represents (numerically,
$\approx(0.924, 0.383)^T$ for $+1$ and $(-0.383, 0.924)^T$ for $-1$).
</details>

**E5 (hard).** Suppose normal operators $A,B$ satisfy $[A,B]=0$ and $A$ has *non-degenerate* spectrum.
Prove that every eigenvector of $A$ is also an eigenvector of $B$, hence $B = f(A)$ for some function $f$.

<details><summary>Solution</summary>

If $A|v\rangle = a|v\rangle$ with $a$ non-degenerate, then $A(B|v\rangle) = BA|v\rangle = aB|v\rangle$,
so $B|v\rangle$ lies in the (1-dimensional) eigenspace of $A$ for $a$; thus $B|v\rangle = b|v\rangle$ for
some scalar $b$ — $|v\rangle$ is an eigenvector of $B$. Defining $f(a) := b$ on the spectrum of $A$ gives
$B = \sum_a f(a)|v_a\rangle\langle v_a| = f(A)$. ∎ (This is why, for a system with a non-degenerate
Hamiltonian, every conserved quantity is a function of the energy.)
</details>

---

## Checkpoint

1. What equation defines an eigenvalue, and how does the characteristic polynomial find them?
2. Define a *normal* operator and state the spectral theorem.
3. Write a general spectral decomposition and give the eigenprojector properties.
4. How do you define $f(A)$ for a normal $A$? Give the example used for time evolution.
5. State the commute ⟺ simultaneously-diagonalizable theorem and its physical meaning.

<details><summary>Answers</summary>

1. $A|v\rangle = \lambda|v\rangle$, i.e. $\det(A-\lambda I)=0$; the roots of that degree-$n$ polynomial
   are the eigenvalues.
2. $A^\dagger A = A A^\dagger$; then $A$ has an orthonormal eigenbasis and $A = \sum_k\lambda_k|v_k\rangle\langle v_k| = U\Lambda U^\dagger$.
3. $A = \sum_k\lambda_k P_k$ with $P_k P_l = \delta_{kl}P_k$, $\sum_k P_k = I$, $P_k$ Hermitian.
4. $f(A) = \sum_k f(\lambda_k)P_k$; e.g. $e^{-iHt} = \sum_k e^{-i\lambda_k t}P_k$.
5. Normal $A,B$ share an orthonormal eigenbasis iff $[A,B]=0$; physically, commuting observables are
   simultaneously measurable with definite joint values.

</details>

---

## Further Reading

- **[Axl]** Axler, *Linear Algebra Done Right*, Ch. 5, 7 — eigenvalues, the spectral theorem (a clean,
  determinant-free treatment).
- **[NC]** Nielsen & Chuang, §2.1.7–2.1.8 — eigendecomposition and the spectral decomposition.
- **[HJ]** Horn & Johnson, *Matrix Analysis*, Ch. 1, 2 — normal matrices, Schur/spectral theorems.

---

← Prev: [Linear Operators & Matrices](04-linear-operators-matrices.md) · Up: [Term 0](../README.md) · Next: [Special Operators](06-special-operators.md) →
