Eigenvalues and eigenvectors
特征值与特征向量
Identify invariant directions, distinguish multiplicities and complex eigenvalues, and test a power iteration by its residual.
eigenvaluesFind directions that keep their line
The matrix sends to and to . Most vectors change direction, but these two stay on their original lines. Their scale factors, three and one, are eigenvalues; the nonzero vectors are eigenvectors.
This separates a transformation into modes. Under repeated application, one direction might grow rapidly, another decay, and another reverse sign each step. Eigenvalues describe this behavior along eigenvectors. They do not automatically describe the maximum stretch of an arbitrary nonsymmetric matrix; singular values answer that different question. MML, Section 4.2
An equation, a null space, and a polynomial
For a square matrix , a right eigenpair satisfies
The last equation says that belongs to the null space of . A nonzero solution exists exactly when that matrix is singular, so
For the opening example, the polynomial is . Substituting each root into the linear system produces its eigenvectors. Multiplying an eigenvector by any nonzero scalar leaves it an eigenvector; normalization fixes length, but still permits a sign flip for real vectors. Deep Learning, Section 2.7
An eigenvalue’s algebraic multiplicity is its multiplicity as a polynomial root. Its geometric multiplicity is the dimension of the corresponding null space. The zero vector belongs to that space but is not itself called an eigenvector. If there are n independent eigenvectors, collect them as columns of :
The inverse requires independent columns. A repeated eigenvalue does not by itself prevent diagonalization: has two independent eigenvectors despite its repeated eigenvalue one. In contrast, has only one independent eigenvector. Its equation for eigenvalue one forces the second coordinate to zero, so no two-vector eigenbasis exists.
Real matrix entries also do not guarantee real eigenvalues. The quarter-turn matrix has characteristic equation . Over the complex numbers its eigenvalues are and ; over the real numbers no nonzero vector remains on its original line. State which field you are using.
One eigenpair by repeated multiplication
For a diagonalizable matrix, write a starting vector as . Then . If one eigenvalue has strictly largest magnitude and its starting coefficient is nonzero, normalization suppresses the other components at ratios governed by . A negative dominant eigenvalue can make the normalized direction alternate sign.
Power iteration uses this observation. The code estimates a real eigenvalue using the Rayleigh quotient of the normalized vector and checks the residual . It returns one approximate pair, not the complete spectrum or a certificate that the returned eigenvalue is dominant.
import math
def power_iteration(a, start, tolerance=1e-10, max_steps=200):
n = len(a)
if not n or len(start) != n or any(len(row) != n for row in a):
raise ValueError("matching nonempty square matrix and vector required")
if any(not math.isfinite(x) for row in a for x in row):
raise ValueError("finite real matrix required")
if any(not math.isfinite(x) for x in start):
raise ValueError("finite start vector required")
if not math.isfinite(tolerance) or tolerance <= 0:
raise ValueError("positive finite tolerance required")
if type(max_steps) is not int or max_steps < 1:
raise ValueError("positive integer step limit required")
length = math.hypot(*start)
if length == 0 or not math.isfinite(length):
raise ValueError("nonzero start with finite norm required")
v = [x/length for x in start]
for _ in range(max_steps):
av = [sum(x*y for x,y in zip(row,v)) for row in a]
value = sum(x*y for x,y in zip(v,av))
residual = math.hypot(*(x-value*y for x,y in zip(av,v)))
if not math.isfinite(value) or not math.isfinite(residual):
raise ArithmeticError("nonfinite iteration")
if residual <= tolerance:
return value, v, residual
length = math.hypot(*av)
if not math.isfinite(length) or length == 0:
raise ArithmeticError("cannot normalize the iterate")
v = [x/length for x in av]
raise RuntimeError("residual tolerance not reached")
value, vector, residual = power_iteration([[2.,1.],[1.,2.]], [1.,0.])
assert abs(value-3.) < 1e-10 and residual < 1e-10
assert abs(abs(vector[0])-1/math.sqrt(2)) < 1e-10
assert abs(power_iteration([[-3.,0.],[0.,1.]], [1.,1.])[0]+3.) < 1e-10
# An exact but non-dominant eigenvector also has residual zero.
assert power_iteration([[3.,0.],[0.,1.]], [0.,1.])[0] == 1.
assert power_iteration([[0.,0.],[0.,0.]], [1.,0.])[0] == 0.
try:
power_iteration([[0.,-1.],[1.,0.]], [1.,0.], max_steps=20)
except RuntimeError:
pass
else:
raise AssertionError("a real eigenvector of a quarter turn cannot exist")
For a dense n×n matrix, each step costs arithmetic operations and working memory. With T steps, the iteration costs in addition to input validation. This implementation uses an absolute residual tolerance, which should be reconsidered when matrix scale changes. It reports failure when the step limit is reached rather than silently presenting an unconverged vector as a result.
A small residual answers only one question
Starting at for returns eigenvalue one immediately. That is a correct eigenpair, but the larger eigenvalue three is absent from the starting vector. A residual test cannot establish that every other eigenvalue is smaller. Equal-magnitude modes, complex pairs, and defective matrices also fall outside the simple convergence explanation.
Near repeated eigenvalues, individual eigenvectors can change substantially under small perturbations. A stable invariant subspace can be more meaningful than insisting that two software runs return identical vectors. For general problems, use an appropriate library solver and check its output conventions: NumPy’s eig returns right eigenvectors as columns and does not promise sorted eigenvalues. NumPy documentation
Test the conditions
- Is the zero vector an eigenvector? Answer: no; allowing it would make every scalar satisfy the defining equation.
- What is for the opening matrix? Answer: .
- Does a repeated eigenvalue imply failure of diagonalization? Answer: no; compare with the defective triangular example.
- Why does the quarter-turn test reach its iteration limit? Answer: a real iterate cannot converge to a nonexistent real eigenvector; its residual remains one in this example.
Connect modes to applications
Covariance analysis, graph methods, and linear dynamics use eigenvectors for different reasons. Covariance matrices add symmetry and semidefiniteness; directed transition matrices add probability constraints; stability questions depend on the update rule. Read the spectral theorem for the stronger result available under symmetry, and SVD for a decomposition that also applies to rectangular and defective matrices.
Make a prediction, then check
Power iteration on diag(3,1) starts at (0,1) and returns 1. What does this establish?
Learning objectives
- Use null spaces and characteristic polynomials to identify eigenpairs and multiplicities.
- Explain the starting-direction condition in power iteration and distinguish an eigenpair residual from dominance.
Prerequisites & connections
Explore related knowledge →References
- Mathematics for Machine Learning — mathematical foundations (2024-01-15 draft)
Marc Peter Deisenroth; A. Aldo Faisal; Cheng Soon Ong · 2020 - Deep Learning — Chapter 2: Linear Algebra
Ian Goodfellow; Yoshua Bengio; Aaron Courville · 2016 - NumPy — numpy.linalg.eig
NumPy developers
Version1 · Editorial status: Recorded technical checks completed
View technical check record (AI)
Codex · 2026-09-05 · Codex technical check: cited-source comparison, derivation and numerical checks, bilingual argument comparison, and executed Python assertions; no independent human peer review.
- Checked power iteration, dominant values and residuals on 60 matrices with known rotated modes; tested negative dominance, the zero matrix, and a rotation without real eigenvectors.
- Distinguished algebraic/geometric multiplicity, normalized sign freedom, and starts missing the dominant direction; small residual is not treated as proof of dominance.
- Compared claims, assumptions, examples, exercises and citations across languages; structural validation additionally compares display equations, code and source lists.
Source locations checked:
- Mathematics for Machine Learning — mathematical foundations (2024-01-15 draft) · §4.2 and §4.4, eigenpairs, multiplicities, defective matrices and diagonalization
- Deep Learning — Chapter 2: Linear Algebra · §2.7, eigendecomposition and real symmetric special case
- NumPy — numpy.linalg.eig · Return conventions and Notes: right eigenvectors, ordering and possible rank deficiency
Related topics