Eigenvectors and Eigenvalues
Most vectors change direction when a matrix acts on them. A few special ones only get longer, shorter or flipped. These are the eigenvectors, and the stretch factors are the eigenvalues. They show how a matrix behaves when you apply it over and over, and they are behind PageRank, vibration analysis, PCA and the stability of simulations.
The definition
Let be an matrix. A nonzero vector is an eigenvector of if
The scalar is the eigenvalue that belongs to . In words: sends to a multiple of itself, so stays on its own line through the origin.
Two details matter:
- is never an eigenvector. holds for every , which would make every number an eigenvalue.
- is allowed. just says that is in the null space of (see Column Space, Row Space and Null Space).
Take :
Checking a candidate
To test whether is an eigenvector, compute and see whether it is a multiple of . With exact arithmetic in SymPy you can compare with directly:
from sympy import Matrix
A = Matrix([[2, 1], [1, 2]])
for v in [Matrix([1, 1]), Matrix([1, -1]), Matrix([1, 0]), Matrix([5, 5])]:
Av = A * v
# v is an eigenvector if Av is a multiple of v: the 2x2 matrix [v | Av] has rank 1
if Matrix.hstack(v, Av).rank() == 1:
lam = Av[0] / v[0] if v[0] != 0 else Av[1] / v[1]
print(list(v), "->", list(Av), " eigenvector, lambda =", lam)
else:
print(list(v), "->", list(Av), " not an eigenvector")[1, 1] -> [3, 3] eigenvector, lambda = 3
[1, -1] -> [1, -1] eigenvector, lambda = 1
[1, 0] -> [2, 1] not an eigenvector
[5, 5] -> [15, 15] eigenvector, lambda = 3
Notice : any nonzero multiple of an eigenvector is again an eigenvector with the same eigenvalue, because .
Eigenspaces
For a fixed eigenvalue , the set of all with is
This is a subspace, called the eigenspace of . It contains (the one vector that is not an eigenvector) plus all the eigenvectors for . So once you know , finding the eigenvectors is plain row reduction of , a homogeneous system as in Homogeneous Systems. How to find in the first place is the topic of Finding Eigenvalues.
| Example matrix | Eigenvalues | Eigenvectors |
|---|---|---|
| (identity) | 1 | every nonzero vector |
| , | multiples of , of | |
| 3, 1 | multiples of , of | |
| a projection onto a line | 1, 0 | vectors on , |
Why repeated application loves eigenvectors
If , then , and in general . A matrix power that is costly on a general vector is trivial on an eigenvector. Write any vector as a combination of eigenvectors and you can see the long-run behaviour: the part along the eigenvector with the largest grows fastest and soon dominates.
That observation is an algorithm, power iteration: start with almost any vector, multiply by again and again, and rescale each time. The direction converges to the dominant eigenvector, and the stretch factor converges to the dominant eigenvalue.
import numpy as np
A = np.array([[2.0, 1.0], [1.0, 2.0]])
v = np.array([1.0, 0.0]) # not an eigenvector
for k in range(1, 9):
w = A @ v
lam = float(np.linalg.norm(w) / np.linalg.norm(v))
v = w / np.linalg.norm(w) # rescale so the numbers stay small
print(f"step {k}: v = ({v[0]:.5f}, {v[1]:.5f}) stretch = {lam:.5f}")step 1: v = (0.89443, 0.44721) stretch = 2.23607
step 2: v = (0.78087, 0.62470) stretch = 2.86356
step 3: v = (0.73279, 0.68045) stretch = 2.98370
step 4: v = (0.71578, 0.69832) stretch = 2.99817
step 5: v = (0.71001, 0.70419) stretch = 2.99980
step 6: v = (0.70808, 0.70614) stretch = 2.99998
step 7: v = (0.70743, 0.70678) stretch = 3.00000
step 8: v = (0.70721, 0.70700) stretch = 3.00000
The direction heads to and the stretch to 3. The error shrinks by the ratio of the two eigenvalues, , at every step.
In software
- PageRank ranks web pages by the dominant eigenvector of a huge link matrix, found by exactly this power iteration (see PageRank and Markov Chains). The matrix is never stored densely; only matrix-vector products are needed.
- PCA finds the directions of greatest variance in data as the eigenvectors of a covariance matrix (Principal Component Analysis).
- Vibration and physics: the natural modes of a structure or a spring network are eigenvectors (Systems of Linear Differential Equations).
- Stability: an iterated update (a simulation step, a recurrent network, a filter) blows up if some and dies out if all .
Note: Eigen is German for "own" or "characteristic". An eigenvector is a vector the matrix treats as its own direction.
Exercises
Exercise 1: Spot the eigenvectors
Which of , and are eigenvectors of ? Give the eigenvalue of each one that is.
Answer
with and with . is not an eigenvector.
Solution
Exercise 2: Eigenvector from a known eigenvalue
has eigenvalue . Find an eigenvector for it.
Answer
Any nonzero multiple of .
Solution
Exercise 3: Powers and shifts
Suppose . Compute , and, if is invertible, , each as a multiple of .
Answer
, , .
Solution
Exercise 4: Power iteration
Run power iteration on , starting from , for 30 steps. Which eigenvalue and which direction does it find?
Answer
, direction . The other eigenvalue is 2, so the error shrinks like .
Solution
By hand: . The rescaled iterates converge to that direction:
import numpy as np
C = np.array([[4.0, 1.0], [2.0, 3.0]])
v = np.array([1.0, 0.0])
for _ in range(30):
w = C @ v
lam = float(v @ w) # Rayleigh quotient (v has length 1)
v = w / np.linalg.norm(w)
print(f"lambda ~ {lam:.6f}, v ~ ({v[0]:.5f}, {v[1]:.5f})")lambda ~ 5.000000, v ~ (0.70711, 0.70711)
Test yourself
Which statement is part of the definition of an eigenvector of ?
- must be nonzero
- is perpendicular to
- must be nonzero and
- must have length 1
If , what is ?
What does power iteration converge to (for a typical starting vector)?
- The eigenvector of the eigenvalue with the largest absolute value
- The eigenvector of the smallest eigenvalue
- The zero vector
- The first column of