---
title: Symmetric matrices
heading: Real eigenvalues and perpendicular axes
eyebrow: A7 · Lesson 41 · Symmetric matrices
xp: 40
---

::: hook
A resistor network's conductance matrix is symmetric. So is the covariance matrix of a set of noisy measurements, the stiffness matrix of a vibrating board, and the inductance matrix of coupled coils. Symmetric matrices are the best-behaved matrices there are: their eigenvalues are always real, their eigenvectors are always perpendicular, and they can always be diagonalized by a rotation. Geometrically, a symmetric matrix is a stretch along perpendicular axes, and nothing more.
:::

::: play
- The ellipse is every $\mathbf{x}$ with $\mathbf{x}^TS\mathbf{x} = 1$, for $S = \begin{bmatrix}a & b\\b & d\end{bmatrix}$.
- The arrows are the eigenvectors. However you set the sliders, they stay perpendicular and point along the ellipse's axes.
- The semi-axes are $\frac{1}{\sqrt{\lambda}}$: the larger eigenvalue gives the shorter axis.
:::
:::

```sim plot
view: complex
range: 1.6
slider: a = 1..4 step 0.1 = 2
slider: b = -0.9..0.9 step 0.05 = 0.6
slider: d = 1..4 step 0.1 = 1.2
curve: (cos(u)/sqrt((a + d)/2 + sqrt(((a - d)/2)^2 + b^2)))*(1∠(0.5*arg((a - d) + j*2*b)*180/pi)) + (sin(u)/sqrt((a + d)/2 - sqrt(((a - d)/2)^2 + b^2)))*(1∠(0.5*arg((a - d) + j*2*b)*180/pi + 90)) | over: u = 0..2*pi | label: xᵀSx = 1
arrow: (1/sqrt((a + d)/2 + sqrt(((a - d)/2)^2 + b^2)))*(1∠(0.5*arg((a - d) + j*2*b)*180/pi)) | color: ch2 | label: q₁
arrow: (1/sqrt((a + d)/2 - sqrt(((a - d)/2)^2 + b^2)))*(1∠(0.5*arg((a - d) + j*2*b)*180/pi + 90)) | color: ch3 | label: q₂
readout: λ₁ = (a + d)/2 + sqrt(((a - d)/2)^2 + b^2) | digits: 4
readout: λ₂ = (a + d)/2 - sqrt(((a - d)/2)^2 + b^2) | digits: 4
```

::: predict
## Can a real symmetric matrix have complex eigenvalues, like a rotation does?

- [x] No: its eigenvalues are always real
- [ ] Yes, if its off-diagonal entries are large
- [ ] Yes, if it has negative entries
- [ ] Only when it's 3 × 3 or bigger

::: reveal
Never. For 2 × 2, the eigenvalues are $\frac{a + d}{2} \pm \sqrt{\left(\frac{a - d}{2}\right)^2 + b^2}$, and the quantity under the root is a sum of squares, so it's never negative. A symmetric matrix stretches along perpendicular axes; it never rotates, so it has no complex eigenvalues.
:::
:::

::: nameit
## The spectral theorem

Every real symmetric matrix $S$ has

- **real eigenvalues**, and
- **orthonormal eigenvectors** (eigenvectors for different eigenvalues are automatically perpendicular; for a repeated eigenvalue you can choose them perpendicular).

So $S$ is diagonalized by an orthogonal matrix:

$$S = Q\Lambda Q^T = \lambda_1\mathbf{q}_1\mathbf{q}_1^T + \cdots + \lambda_n\mathbf{q}_n\mathbf{q}_n^T$$

The second form says $S$ is a sum of projections onto its eigenvectors, each weighted by its eigenvalue.

## Why the eigenvectors are perpendicular

If $S\mathbf{x} = \lambda\mathbf{x}$ and $S\mathbf{y} = \mu\mathbf{y}$ with $\lambda \ne \mu$, then $\lambda\mathbf{y}^T\mathbf{x} = \mathbf{y}^TS\mathbf{x} = (S\mathbf{y})^T\mathbf{x} = \mu\mathbf{y}^T\mathbf{x}$, using $S^T = S$. Since $\lambda \ne \mu$, $\mathbf{y}^T\mathbf{x} = 0$.

## Quadratic forms

The number $\mathbf{x}^TS\mathbf{x}$ is a **quadratic form**, such as $2x^2 + 2xy + 2y^2$. In the eigenvector coordinates it becomes $\lambda_1y_1^2 + \cdots + \lambda_ny_n^2$, with no cross terms: the eigenvectors are the **principal axes**. The **Rayleigh quotient** $\frac{\mathbf{x}^TS\mathbf{x}}{\mathbf{x}^T\mathbf{x}}$ always lies between the smallest and largest eigenvalue, reaching them along the eigenvectors.

## Where they appear

- **Conductance matrices** of resistor networks (reciprocity, lesson 11).
- **Covariance matrices** of noisy data: the eigenvectors are the directions of greatest and least spread (principal components, A11 and S14).
- **Energy:** stored energies like $\frac{1}{2}\mathbf{v}^TC\mathbf{v}$ in a capacitor network are quadratic forms.
:::

::: example
## Diagonalize $S = \begin{bmatrix}2 & 1\\1 & 2\end{bmatrix}$ and write it as a sum of projections.

::: solution
1. **Eigenvalues and unit eigenvectors.** The eigenvalues are $2 \pm 1$: $\lambda_1 = 3$ with $\mathbf{q}_1 = \frac{1}{\sqrt 2}(1, 1)$, and $\lambda_2 = 1$ with $\mathbf{q}_2 = \frac{1}{\sqrt 2}(1, -1)$.
2. **Sum of projections.**
   $$\begin{aligned} &3\cdot\frac{1}{2}\begin{bmatrix}1 & 1\\1 & 1\end{bmatrix} \\ &\quad + 1\cdot\frac{1}{2}\begin{bmatrix}1 & -1\\-1 & 1\end{bmatrix} \\ &= \begin{bmatrix}2 & 1\\1 & 2\end{bmatrix} \end{aligned}$$

**Answer:** $S = 3\mathbf{q}_1\mathbf{q}_1^T + 1\mathbf{q}_2\mathbf{q}_2^T$, with $\mathbf{q}_1 = \frac{1}{\sqrt 2}(1, 1)$ and $\mathbf{q}_2 = \frac{1}{\sqrt 2}(1, -1)$.
:::
:::

::: example
## Describe the curve $2x^2 + 2xy + 2y^2 = 1$.

::: solution
1. **Write it as a quadratic form.** It's $\mathbf{x}^TS\mathbf{x} = 1$ for the $S$ above.
2. **Change to eigenvector coordinates.**
   $$3y_1^2 + y_2^2 = 1$$
3. **Read off the axes.** It's an ellipse with semi-axis $\frac{1}{\sqrt 3} = 0.577$ along $(1, 1)$ and semi-axis 1 along $(1, -1)$.

**Answer:** an ellipse, with semi-axis 0.577 along $(1, 1)$ and 1 along $(1, -1)$.
:::
:::

::: example
## What are the largest and smallest values of $x^2 + 4xy + y^2$ on the unit circle?

::: solution
1. **Write it as a quadratic form.** It's $\mathbf{x}^TS\mathbf{x}$ with
   $$S = \begin{bmatrix}1 & 2\\2 & 1\end{bmatrix}$$
2. **Range on the unit circle.** There the quadratic form ranges between the smallest and largest eigenvalues of $S$, which are $-1$ and 3.
3. **Where they're reached.** The maximum, 3, is reached along the eigenvector $\frac{1}{\sqrt2}(1, 1)$, and the minimum, $-1$, along $\frac{1}{\sqrt2}(1, -1)$.
4. **Check the first.**
   $$\tfrac12 + 4 \cdot \tfrac12 + \tfrac12 = 3$$

**Answer:** the largest value is 3 and the smallest is $-1$.
:::
:::

::: check
given: s = 2 | 5; b = -1 | -3
answer: s + abs(b)

## What is the larger eigenvalue of $\begin{bmatrix}\given{s} & \given{b}\\\given{b} & \given{s}\end{bmatrix}$?

::: right
Right. The eigenvalues are $s \pm b$, with eigenvectors $(1, 1)$ and $(1, -1)$: the larger is {answer}.
:::

::: misses
- [s + b] With $b$ negative, $s - b$ is the larger one.
- [s] The off-diagonal entries move the eigenvalues apart.
- [any] Not yet. Try $(1, 1)$ and $(1, -1)$ as eigenvectors.
:::
:::

::: check
given: a = 3 | 5; b = 1 | 2; d = 1 | 2
answer: (a + d)/2 + sqrt(((a - d)/2)^2 + b^2)
tolerance: 0.5%

## What is the larger eigenvalue of $\begin{bmatrix}\given{a} & \given{b}\\\given{b} & \given{d}\end{bmatrix}$?

::: right
Right. $\frac{a + d}{2} + \sqrt{\left(\frac{a - d}{2}\right)^2 + b^2}$ = {answer}.
:::

::: misses
- [a] The coupling $b$ pushes the eigenvalues apart, past the diagonal entries.
- [any] Not yet. Solve $\lambda^2 - (a + d)\lambda + (ad - b^2) = 0$.
:::
:::

::: check
given: s = 4 | 6; b = 1 | 2
answer: 1/sqrt(s - b)
tolerance: 0.5%

## The ellipse $\mathbf{x}^TS\mathbf{x} = 1$ has $S = \begin{bmatrix}\given{s} & \given{b}\\\given{b} & \given{s}\end{bmatrix}$. How long is its longer semi-axis?

::: right
Right. The longer axis goes with the smaller eigenvalue, $s - b$: $\frac{1}{\sqrt{s - b}}$ = {answer}.
:::

::: misses
- [1/sqrt(s + b)] That's the shorter axis: the bigger eigenvalue squeezes more.
- [sqrt(s - b)] Along an eigenvector, $\lambda r^2 = 1$, so $r = 1/\sqrt\lambda$.
- [any] Not yet. Semi-axis $= 1/\sqrt{\lambda}$.
:::
:::

::: check
given: a = 2 | 4; b = 1 | -1; d = 3 | 5
answer: (a + 2*b + d)/2
tolerance: 0.5%

## What is the Rayleigh quotient $\frac{\mathbf{x}^TS\mathbf{x}}{\mathbf{x}^T\mathbf{x}}$ for $S = \begin{bmatrix}\given{a} & \given{b}\\\given{b} & \given{d}\end{bmatrix}$ and $\mathbf{x} = (1, 1)$?

::: right
Right. $\mathbf{x}^TS\mathbf{x} = a + 2b + d$ and $\mathbf{x}^T\mathbf{x} = 2$: {answer}.
:::

::: misses
- [a + 2*b + d] Divide by $\mathbf{x}^T\mathbf{x} = 2$.
- [(a + b + d)/2] The cross term appears twice: $2b$.
- [any] Not yet. Compute $\mathbf{x}^TS\mathbf{x}$, then divide.
:::
:::

::: check
given: l1 = 5 | 7; l2 = 1 | 2
answer: (l1 - l2)/2

## $S$ has eigenvalue {l1} along $\frac{1}{\sqrt 2}(1, 1)$ and {l2} along $\frac{1}{\sqrt 2}(1, -1)$. What is its off-diagonal entry?

::: right
Right. $S = \lambda_1\mathbf{q}_1\mathbf{q}_1^T + \lambda_2\mathbf{q}_2\mathbf{q}_2^T$, whose off-diagonal is $\frac{\lambda_1 - \lambda_2}{2}$ = {answer}.
:::

::: misses
- [(l1 + l2)/2] That's each diagonal entry.
- [any] Not yet. Build $S$ from its eigenvalues and eigenvectors.
:::
:::

::: check
kind: choice

## $S$ is real and symmetric with eigenvalues 2 and 5. What can you say about its eigenvectors?

- [x] They're perpendicular
- [ ] They're parallel
- [ ] They could be at any angle
- [ ] They're complex

::: right
Right. Different eigenvalues of a symmetric matrix always have perpendicular eigenvectors.
:::

::: misses
- [3] For a general matrix yes, but symmetry forces them perpendicular.
- [any] Use $S^T = S$.
:::
:::

::: check
kind: parts
given: a = 2 | 3 | 5; b = 1 | 4

## The quadratic form $\given{a}x^2 + 2\cdot\given{b}xy + \given{a}y^2$ on the unit circle.

::: part
answer: a + b
tolerance: 0.5%

### What is its largest value?

::: misses
- [a] The cross term adds along $(1, 1)$.
- [any] The largest eigenvalue of $\begin{bmatrix}a & b\\b & a\end{bmatrix}$.
:::
:::

::: part
answer: a - b
tolerance: 0.5%

### What is its smallest value?

::: misses
- [any] The smallest eigenvalue, along $(1, -1)$.
:::
:::
:::

::: check
kind: derivation
vars: x = 0.5..3, y = 0.1..2

## Take $S = \begin{bmatrix}x & y\\y & x\end{bmatrix}$.

::: step
answer: x + y

### What is the eigenvalue for $(1, 1)$?
:::

::: step
answer: x^2 + y^2

### What is the top-left entry of $S^2$?
:::

::: right
Right. $S^2$ has eigenvalues $(x \pm y)^2$, and its top-left entry is their average, $x^2 + y^2$.
:::
:::

::: explain
## Explain geometrically what a symmetric matrix does to the plane.

::: model
A symmetric matrix has two perpendicular eigenvector directions, and it simply stretches the plane along each one by its eigenvalue (flipping it if the eigenvalue is negative). There's no rotation: $S = Q\Lambda Q^T$ means rotate into the eigenvector axes, stretch along each axis, and rotate back. That's why the unit circle maps to an ellipse whose axes are the eigenvectors, and why the curve $\mathbf{x}^TS\mathbf{x} = 1$ is an ellipse along those same axes when the eigenvalues are positive.
:::
:::

::: practice

::: check
given: s = 3 | 6; b = 1 | 2
answer: s - b

## What is the smaller eigenvalue of $\begin{bmatrix}\given{s} & \given{b}\\\given{b} & \given{s}\end{bmatrix}$?

::: misses
- [s + b] That's the larger one.
- [any] $s - b$, along $(1, -1)$.
:::
:::

::: check
given: a = 4 | 6; d = 1 | 2
answer: a

## What is the larger eigenvalue of $\begin{bmatrix}\given{a} & 0\\0 & \given{d}\end{bmatrix}$?

::: misses
- [d] That's the smaller.
- [any] A diagonal matrix's eigenvalues are its diagonal entries.
:::
:::

::: check
given: l1 = 4 | 9; l2 = 1 | 2
answer: (l1 + l2)/2

## $S$ has eigenvalue {l1} along $\frac{1}{\sqrt 2}(1, 1)$ and {l2} along $\frac{1}{\sqrt 2}(1, -1)$. What is its top-left entry?

::: misses
- [(l1 - l2)/2] That's the off-diagonal entry.
- [any] $\frac{\lambda_1 + \lambda_2}{2}$.
:::
:::
:::
