AI Wiki中文/EN

Eigenvalues and eigenvectors

特征值与特征向量

Identify invariant directions, distinguish multiplicities and complex eigenvalues, and test a power iteration by its residual.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

Find directions that keep their line

The matrix A=[2112]A=\begin{bmatrix}2&1\\1&2\end{bmatrix} sends (1,1)(1,1) to (3,3)(3,3) and (1,−1)(1,-1) to (1,−1)(1,-1). 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 AA, a right eigenpair satisfies

Av=λv,v≠0,(A−λI)v=0.Av=\lambda v,\qquad v\ne0,\qquad (A-\lambda I)v=0.

The last equation says that vv belongs to the null space of A−λIA-\lambda I. A nonzero solution exists exactly when that matrix is singular, so

det⁡(A−λI)=0.\det(A-\lambda I)=0.

For the opening example, the polynomial is (2−λ)2−1=(λ−3)(λ−1)(2-\lambda)^2-1=(\lambda-3)(\lambda-1). 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 VV:

AV=VΛ,A=VΛV−1,Ak=VΛkV−1.AV=V\Lambda,\qquad A=V\Lambda V^{-1},\qquad A^k=V\Lambda^kV^{-1}.

The inverse requires independent columns. A repeated eigenvalue does not by itself prevent diagonalization: I2I_2 has two independent eigenvectors despite its repeated eigenvalue one. In contrast, [1101]\begin{bmatrix}1&1\\0&1\end{bmatrix} 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 [0−110]\begin{bmatrix}0&-1\\1&0\end{bmatrix} has characteristic equation λ2+1=0\lambda^2+1=0. Over the complex numbers its eigenvalues are ii and −i-i; 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 v0=∑iciviv_0=\sum_i c_i v_i. Then Akv0=∑iciλikviA^kv_0=\sum_i c_i\lambda_i^k v_i. If one eigenvalue has strictly largest magnitude and its starting coefficient is nonzero, normalization suppresses the other components at ratios governed by ∣λi/λ1∣k|\lambda_i/\lambda_1|^k. 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 ∥Av−λv∥2\|Av-\lambda v\|_2. 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 O(n2)O(n^2) arithmetic operations and O(n)O(n) working memory. With T steps, the iteration costs O(Tn2)O(Tn^2) 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 (0,1)(0,1) for diag⁡(3,1)\operatorname{diag}(3,1) 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

  1. Is the zero vector an eigenvector? Answer: no; allowing it would make every scalar satisfy the defining equation.
  2. What is A3(1,1)A^3(1,1) for the opening matrix? Answer: 33(1,1)=(27,27)3^3(1,1)=(27,27).
  3. Does a repeated eigenvalue imply failure of diagonalization? Answer: no; compare I2I_2 with the defective triangular example.
  4. 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?

Choose one answer

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

  1. Mathematics for Machine Learning — mathematical foundations (2024-01-15 draft)
    Marc Peter Deisenroth; A. Aldo Faisal; Cheng Soon Ong · 2020
  2. Deep Learning — Chapter 2: Linear Algebra
    Ian Goodfellow; Yoshua Bengio; Aaron Courville · 2016
  3. 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:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.