The Spectral Theorem#
A real matrix is symmetric when — every entry equals its transpose partner, so . Symmetric matrices appear everywhere: covariance matrices, Hessian matrices of smooth functions, graph Laplacians, and Gram matrices of the form . This week is about what symmetry buys you algebraically and geometrically.
The spectral theorem is the central fact:
Every real symmetric matrix has real eigenvalues (counting multiplicity) and an orthonormal basis of eigenvectors . In matrix form
where and is an orthogonal matrix (, so ) whose columns are the eigenvectors.
Compare with ordinary diagonalization from Week 10. Symmetry upgrades two things at once:
- All eigenvalues are real — no complex conjugate pairs, no hidden oscillation from imaginary parts.
- The eigenvector matrix can be chosen orthogonal — is simply , and the change of coordinates is a pure rotation/reflection (an isometry of ).
Why eigenvectors for distinct eigenvalues are orthogonal. Suppose , , with and . Take the inner product:
So . Because , we must have : the eigenvectors are orthogonal. When eigenvalues repeat, you can still orthonormalize within each eigenspace (Gram–Schmidt from Week 7) and keep different eigenspaces orthogonal. The result is always an orthonormal basis of .
Worked check. Let
Trace , determinant , so eigenvalues solve : , . For :
For :
Indeed , and
(You can verify and by direct multiplication.)
Quadratic Forms#
A quadratic form is a scalar function of a vector built from a symmetric matrix:
In components for with this is
(The off-diagonal contributes twice because and both equal .) Quadratic forms measure energy, squared length after a linear map (), and second-order Taylor terms of a smooth function near a critical point.
Diagonalization simplifies the form. Write and change variables to the eigen-coordinates (so ). Then
The cross terms vanish. In the eigenvector basis, the quadratic form is a pure weighted sum of squares: . That is why the spectral theorem is the engine of everything that follows — positive definiteness, ellipses, and (next week) the SVD all reduce to the signs and sizes of the .
Example. For the matrix above with ,
in the -coordinates. Along the first eigen-direction the form grows thrice as fast as along the second.
Positive Definite Matrices#
A symmetric matrix is positive definite (often written ) when
If the inequality is instead of , is positive semidefinite. Negative definite means for all (equivalently, is positive definite).
Positive definite matrices are the multivariable analogue of a positive number: they define genuine energies, strict convexity of , and unique minima of associated least-squares problems. Three classical tests decide positive definiteness — all equivalent for real symmetric .
Test 1 — Eigenvalues#
From the spectral form with and (because is orthogonal), we get:
- is positive definite every eigenvalue .
- is positive semidefinite every .
- is indefinite if some and some (the form takes both positive and negative values).
This is usually the conceptual test: stretch factors in every eigen-direction must be positive.
Test 2 — Pivots#
Eliminate by Gaussian elimination without row exchanges (or more carefully: with pivots that stay on the diagonal when possible). The successive pivots that appear on the diagonal of the upper-triangular factor are all positive if and only if is positive definite. Equivalently, the LDL factorization has a positive diagonal .
Test 3 — Leading principal minors (determinants)#
Let be the upper-left principal submatrix of (the first rows and columns). The leading principal minors are . Sylvester's criterion:
For a matrix this is simply and .
Worked example. Take again
- Eigenvalues: and , both positive positive definite.
- Pivots: first pivot ; after eliminating, the Schur complement is . Both pivots positive.
- Leading determinants: and .
All three tests agree. Contrast with : eigenvalues and , so is indefinite — already fails the leading-determinant test.
Why three tests? Eigenvalues are conceptual. Pivots are computational during elimination. Leading determinants are a quick hand check for small . Use whichever is handy; they always give the same yes/no answer for symmetric .
Geometric Picture#
Fix a positive definite and a positive constant . The level set
is a closed bounded surface around the origin. In the eigen-coordinates the equation becomes
or equivalently
That is the standard equation of an ellipse when , and an ellipsoid when . The geometry is completely determined by the spectral data:
| Feature | Determined by | |---|---| | Orientation of the axes | Eigenvectors (columns of ) | | Axis half-lengths for level | along eigenvector | | “Fatness” vs “thinness” | Ratio of eigenvalues (condition number of ) |
Large means a short axis: the quadratic form grows quickly in that direction, so the level set is reached sooner. Small means a long axis. When one eigenvalue is much larger than another, the ellipse is elongated along the small-eigenvalue direction.
If is not positive definite. Zero eigenvalues open the level set into a cylinder (unbounded in the null direction). Opposite-sign eigenvalues produce hyperbolas — the form is indefinite and the “energy” can be positive, zero, or negative depending on direction.
Preview of Week 13. For any matrix (not necessarily square), the Gram matrix is always symmetric and positive semidefinite. Its eigenvalues are the squared singular values of , and its eigenvectors are the right singular vectors. The spectral theorem for is the algebraic core of the SVD — the next lesson's main tool.
Knowledge check#
Test A = [[2,-1],[-1,2]] for positive definiteness using leading determinants. The first leading determinant is 2. What is the second leading determinant (the full det(A))?
Browser lab#
Check positive definiteness via eigenvalues and plot the quadratic form's level set.
import numpy as np
import matplotlib.pyplot as plt
A = np.array([[2., -1.],
[-1., 2.]])
eigvals = np.linalg.eigvalsh(A)
print("eigenvalues =", eigvals)
print("positive definite:", np.all(eigvals > 0))
theta = np.linspace(0, 2 * np.pi, 200)
circle = np.array([np.cos(theta), np.sin(theta)])
vals, vecs = np.linalg.eigh(A)
ellipse = vecs @ np.diag(1 / np.sqrt(vals)) @ circle
fig, ax = plt.subplots(figsize=(5, 5))
ax.plot(ellipse[0], ellipse[1])
ax.set_aspect("equal")
ax.set_title(r"Level set $x^TAx = 1$")
plt.show()
np.linalg.eigvalsh / eigh are the symmetric (Hermitian) variants of the eigensolvers — they return real eigenvalues sorted ascending and an orthogonal eigenvector matrix. The construction maps the unit circle to the ellipse : half-axis lengths are along the eigenvectors, matching the geometric picture above.
Quiz#
The spectral theorem guarantees that a real symmetric matrix has: