Eigenvalues and Eigenvectors
Eigenvalues and eigenvectors are special scalar-vector pairs associated with a square matrix A, where multiplying the matrix by the vector produces the same result as scaling the vector by the scalar: Av = λv. They are foundational to modern AI/ML — powering dimensionality reduction (PCA), graph neural networks, spectral clustering, and understanding why deep networks train or fail to train at all. The remarkable fact: a symmetric matrix's eigenvectors are always mutually orthogonal, meaning nature "chooses" maximally independent directions to encode its transformations.
A matrix encodes a linear transformation — rotations, stretches, shears — but hidden inside every such transformation are special directions that only get scaled, never rotated. These are the eigenvectors, and how much they get scaled is the eigenvalue. The "aha moment" is realizing that decomposing a matrix into its eigenvectors and eigenvalues is equivalent to finding the natural coordinate system in which the transformation becomes trivially simple: just multiply each axis by a scalar. Almost everything hard about a matrix becomes easy once you find that coordinate system.
How It Works
The Defining Equation
The entire theory starts from one deceptively simple equation. For a square matrix A ∈ ℝⁿˣⁿ, a nonzero vector v ∈ ℝⁿ is an eigenvector if:
Explanation: Multiplying the matrix <strong>A</strong> by the vector <strong>v</strong> is identical to stretching (or flipping) <strong>v</strong> by the scalar λ — the vector's direction is preserved, only its magnitude changes. Here, A is any square matrix, v is the eigenvector (a nonzero column vector), and λ (lambda) is the corresponding eigenvalue — a real or complex scalar. Note that v = 0 is explicitly excluded because it satisfies the equation trivially for any λ.
Finding Eigenvalues: The Characteristic Equation
Rearranging [1]:
Explanation: This says the matrix (<strong>A</strong> − λ<strong>I</strong>) maps the nonzero vector <strong>v</strong> to zero, which is only possible if that matrix is singular (non-invertible). For a non-trivial solution (v ≠ 0) to exist, (A − λI) must be singular — it must "collapse" some direction to zero. A matrix is singular if and only if its determinant is zero, giving the characteristic equation:
Explanation: Expanding this determinant produces a degree-n polynomial in λ (the characteristic polynomial), whose roots are exactly the n eigenvalues of <strong>A</strong>. For a 2×2 matrix, this yields a quadratic; for a 3×3, a cubic — and so on. Once eigenvalues are found, each eigenvector is obtained by solving the linear system (A − λᵢI)v = 0 via Gaussian elimination.
Eigendecomposition
When A has n linearly independent eigenvectors (it is diagonalizable), we can write the full eigendecomposition:
Explanation: <strong>A</strong> is factored into a matrix of eigenvectors <strong>Q</strong>, a diagonal matrix <strong>Λ</strong> of eigenvalues, and the inverse of <strong>Q</strong> — meaning the transformation is a change of basis, a pure scaling, and then a change back. Here Q = [v₁ | v₂ | … | vₙ] (columns are eigenvectors), and Λ = diag(λ₁, λ₂, …, λₙ). For symmetric matrices (A = Aᵀ), the Spectral Theorem guarantees eigenvectors are orthonormal, so Q⁻¹ = Qᵀ, giving the cleaner form:
Explanation: For symmetric matrices, the change-of-basis matrix is also an orthogonal rotation matrix — the eigenvectors form a perfectly perpendicular coordinate system aligned with the matrix's natural "stretch directions."
PyTorch Implementation
```python import torch
# Define a symmetric matrix (e.g., a covariance matrix) A = torch.tensor([[4.0, 2.0], [2.0, 3.0]])
# Compute eigenvalues and eigenvectors
# torch.linalg.eigh is for symmetric/Hermitian matrices (guaranteed real eigenvalues) eigenvalues, eigenvectors = torch.linalg.eigh(A) print("Eigenvalues:", eigenvalues)
# tensor([1.5858, 5.4142]) print("Eigenvectors (columns):\n", eigenvectors)
# Each column is a unit eigenvector
# Verify: A @ v ≈ λ v v0 = eigenvectors[:, 0] lam0 = eigenvalues[0] print("Av:", A @ v0) print("λv:", lam0 v0)
# Should be equal (up to floating point)
# Reconstruct A from eigendecomposition Q = eigenvectors Lambda = torch.diag(eigenvalues) A_reconstructed = Q @ Lambda @ Q.T print("Reconstruction error:", torch.norm(A - A_reconstructed).item())
# ≈ 0.0
# For general (non-symmetric) matrices — may return complex eigenvalues B = torch.tensor([[0.0, -1.0], [1.0, 0.0]]) # 90° rotation matrix evals, evecs = torch.linalg.eig(B) print("Complex eigenvalues of rotation:", evals)
# tensor([0.+1.j, 0.-1.j]) — pure imaginary, as expected ```
Hilbert was a German mathematician who dominated early 20th-century mathematics, reformulating geometry, logic, and analysis. He extended eigenvalue theory from finite matrices to infinite-dimensional function spaces, creating spectral theory — the foundation of quantum mechanics and modern functional analysis. Surprisingly, Hilbert himself declared that physics would never find a use for his spectral theory within his lifetime; Max Born had to inform him that Heisenberg's matrix mechanics was precisely that application, just six years later.
Intuition
Imagine you have a lump of dough and you press it with your palms — stretching it in one direction and squishing it in another. No matter how you oriented your hands, the dough has two special directions: one it stretches along (large eigenvalue), one it compresses along (small eigenvalue). Any other direction the dough moves in is just a combination of these two. The eigenvectors are those "principal stretch directions" baked into the material itself, and the eigenvalues tell you how violently it stretches or contracts in each. Now replace "dough" with your data covariance matrix: PCA is simply finding those natural stretch directions in your data cloud. A direction with a large eigenvalue is one your data varies along a lot; a small eigenvalue means the data is nearly flat in that direction — and you can safely discard it without losing much information. For neural networks, the same logic applies to the loss landscape's curvature: large eigenvalues of the Hessian mean the loss is very steep in that direction (dangerous for learning rate), while near-zero eigenvalues mean flat directions (slow to optimize).
Historical Development
Origins · 1 minhow this was discovered
Why It Matters
Prerequisites
What This Leads To
See Also
Singular Value Decomposition (SVD) · Principal Component Analysis (PCA) · Matrix Factorization · Spectral Clustering · Linear Algebra for Machine Learning