M03.3 · Symmetric matrices and the spectral theorem
M03.3 L2 · Intermediate 4 lessons · about 100 min Live · in review
Part of M03 Linear Algebra II: Decompositions in the Mathematics track.
The matrices that machine learning hands to an eigenvalue routine, covariance matrices, Gram matrices, matrices of second derivatives and graphs, are nearly always symmetric, and symmetry buys a great deal. These four lessons prove that a symmetric matrix has real eigenvalues and perpendicular eigenvectors, that it always factors as Q Lambda Q-transpose (turn, stretch along the axes, turn back), that it is a sum of scaled projections onto perpendicular lines, and that its largest and smallest eigenvalues are the extremes of the Rayleigh quotient: the fact behind the first direction of principal component analysis.
What you need first. Eigenvalues, eigenvectors and the characteristic polynomial (M03.1), diagonalisation as A = P D P inverse (M03.2), dot products and projection onto a line (M02.3), orthogonal matrices and Gram-Schmidt (M02.10), and complex conjugates (M01.9). Covariance (M06.10) and partial derivatives (M04.10) supply examples.
Lessons
Real eigenvalues, perpendicular eigenvectors M03.3.1 25 min
A symmetric matrix equals its own mirror image across the diagonal. Prove that its eigenvalues are always real and that eigenvectors for different eigenvalues are always perpendicular, and meet the covariance, Gram, second-derivative and graph matrices where this matters.
The spectral theorem M03.3.2 25 min
Every real symmetric matrix factors as S = Q Lambda Q-transpose with Q orthogonal: turn into the eigenbasis, stretch along the axes, turn back. Prove it for 2 by 2 in full, see the induction for any size, handle repeated eigenvalues with Gram-Schmidt, and check it with numpy.linalg.eigh.
A sum of rank-one pieces M03.3.3 25 min
Multiply out S = Q Lambda Q-transpose and a symmetric matrix falls apart into a weighted sum of projections onto perpendicular lines. Use the pieces to act on a vector, to build S inverse, S to a power and the square root of S, and to glimpse low-rank approximation.
The Rayleigh quotient and the extreme directions M03.3.4 25 min
The Rayleigh quotient x-transpose S x over x-transpose x is a weighted average of the eigenvalues, so it always lies between the smallest and the largest. For a covariance matrix it is the variance along a direction, which makes the top eigenvector the direction of greatest spread: the first step of PCA.
The interactive
M03.3-X1 · Spectral ellipse. Three sliders set a symmetric matrix [[a, b], [b, c]]. The unit circle and its image are drawn with the two perpendicular eigenvectors on the axes of the image ellipse, and a toggle splits the matrix into its two rank-one pieces to show what each does to a chosen vector. It lives in The spectral theorem.