Skip to content

Eigenvalues and Eigenvectors

Most vectors, when hit by a matrix, get both rotated and stretched. But a few special directions get only stretched — the matrix leaves their line alone and just scales them. Those directions are eigenvectors, and the scale factors are eigenvalues. This “eigen-analysis” reveals the true axes of a transformation and is the mathematical core of PCA, spectral clustering, PageRank, and the stability analysis of dynamical systems.

A real-life example: PageRank

Google’s original PageRank models web surfing as a giant matrix AA of click probabilities. Multiply an importance vector by AA over and over and it converges to a special vector that AA merely scales — the eigenvector with the largest eigenvalue. That steady-state vector is the ranking of every web page. Eigenvectors are, literally, what pages Google shows you first.

The eigenvalue equation

For a square matrix AA, a nonzero vector x\mathbf{x} is an eigenvector with eigenvalue λ\lambda if

Ax=λx.A\mathbf{x} = \lambda\mathbf{x}.

In words: applying AA to x\mathbf{x} gives back the same direction, just scaled by λ\lambda. If λ>1\lambda > 1 it stretches, 0<λ<10 < \lambda < 1 it shrinks, λ<0\lambda < 0 it flips.

Eigenvectors are the directions that don’t turn

Watch a probe vector rotate around the circle. For a generic direction the output AxA\mathbf{x} (green) points somewhere different from the input (white) — the matrix rotated it. But along the eigenvector lines (amber), the output stays perfectly parallel to the input, only longer or shorter. Those aligned moments are the eigenvectors:

sketch Eigenvectors: directions a matrix only scales p5.js
A probe vector x (white) rotates; its image Ax (green) generally points a different way. Along the two eigenvector directions (amber lines), Ax stays parallel to x — the matrix only stretches it by the eigenvalue.

Finding them: the characteristic polynomial

λ\lambda is an eigenvalue exactly when AλIA - \lambda I is singular, i.e. when

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

The roots of this characteristic polynomial are the eigenvalues. For each λ\lambda, the eigenvectors are the nonzero solutions of (AλI)x=0(A - \lambda I)\mathbf{x} = \mathbf{0} — i.e. the null space of AλIA - \lambda I, called the eigenspace EλE_\lambda.

Multiplicities and defective matrices

  • The algebraic multiplicity of λ\lambda is how many times it’s a root of pAp_A.
  • The geometric multiplicity is dimEλ\dim E_\lambda — how many independent eigenvectors it has.
  • Geometric \le algebraic, always. When a matrix has fewer than nn independent eigenvectors it’s called defective and cannot be diagonalized.
diagram Diagram mermaid

The spectral theorem

A special, beautiful case: if AA is symmetric (A=AA = A^\top), then it always has real eigenvalues and an orthonormal basis of eigenvectors. Symmetric matrices are never defective. This is why covariance matrices (symmetric, positive semi-definite) always decompose cleanly — the guarantee that makes PCA work.

NumPy

eigen.py
import numpy as np
 
A = np.array([[2.0, 1.0],
              [1.0, 2.0]])
 
vals, vecs = np.linalg.eig(A)
print("eigenvalues:", np.round(vals, 4))          # [1. 3.]  (order may vary)
print("eigenvectors (columns):\n", np.round(vecs, 4))
 
# verify A x = λ x for the first eigenpair
lam, x = vals[0], vecs[:, 0]
print("A x =", np.round(A @ x, 4))
print("λ x =", np.round(lam * x, 4))
print("match:", np.allclose(A @ x, lam * x))
 
# symmetric matrices: use eigh for real eigenvalues + orthonormal eigenvectors
w, Q = np.linalg.eigh(A)
print("orthonormal eigenvectors:", np.allclose(Q.T @ Q, np.eye(2)))
eigen.py
import numpy as np
 
A = np.array([[2.0, 1.0],
              [1.0, 2.0]])
 
vals, vecs = np.linalg.eig(A)
print("eigenvalues:", np.round(vals, 4))          # [1. 3.]  (order may vary)
print("eigenvectors (columns):\n", np.round(vecs, 4))
 
# verify A x = λ x for the first eigenpair
lam, x = vals[0], vecs[:, 0]
print("A x =", np.round(A @ x, 4))
print("λ x =", np.round(lam * x, 4))
print("match:", np.allclose(A @ x, lam * x))
 
# symmetric matrices: use eigh for real eigenvalues + orthonormal eigenvectors
w, Q = np.linalg.eigh(A)
print("orthonormal eigenvectors:", np.allclose(Q.T @ Q, np.eye(2)))
text
eigenvalues: [1. 3.]
eigenvectors (columns):
 [[-0.7071  0.7071]
 [ 0.7071  0.7071]]
A x = [-0.7071  0.7071]
λ x = [-0.7071  0.7071]
match: True
orthonormal eigenvectors: True
text
eigenvalues: [1. 3.]
eigenvectors (columns):
 [[-0.7071  0.7071]
 [ 0.7071  0.7071]]
A x = [-0.7071  0.7071]
λ x = [-0.7071  0.7071]
match: True
orthonormal eigenvectors: True

Why this matters for ML

  • PCA diagonalizes the covariance matrix; its eigenvectors are the principal directions, eigenvalues the variance along each.
  • PageRank / spectral clustering read structure off the leading eigenvectors of a graph matrix.
  • Optimization & stability: the eigenvalues of the Hessian tell you whether a critical point is a min, max, or saddle, and how fast gradient descent converges.

🧪 Try It Yourself

Exercise 1 – Compute eigenvalues and eigenvectors

Exercise 2 – Verify the eigenvalue equation

Exercise 3 – Symmetric ⇒ orthonormal eigenvectors

Recap

  • An eigenvector is a direction a matrix only scales: Ax=λxA\mathbf{x} = \lambda\mathbf{x}; λ\lambda is the eigenvalue.
  • Eigenvalues are roots of the characteristic polynomial det(AλI)=0\det(A - \lambda I) = 0; eigenvectors span the eigenspace (null space of AλIA - \lambda I).
  • Defective matrices lack nn independent eigenvectors; symmetric matrices never do (spectral theorem: real eigenvalues, orthonormal eigenvectors).
  • These drive PCA, PageRank, spectral clustering, and stability analysis.

Next: a specialized “square root” for symmetric positive-definite matrices — Cholesky Decomposition.

If this helped you, consider buying me a coffee ☕

Buy me a coffee

Was this page helpful?

Let us know how we did