Finding Eigenvalues
An eigenvalue is a number for which squashes some nonzero vector to zero. That happens exactly when is not invertible, so its determinant is zero. This turns the hunt for eigenvalues into finding the roots of a polynomial, the characteristic polynomial.
The characteristic equation
with is the same as with . A square matrix has a nonzero null vector exactly when it is singular, and by Properties of Determinants that means its determinant is 0:
For an matrix, is a polynomial of degree in , the characteristic polynomial. Its roots are the eigenvalues, so an matrix has at most distinct eigenvalues. (Some books use , which differs only by the sign and has the same roots.)
The full recipe:
- Compute and find its roots
- For each root, row reduce and read off the null space. Those vectors (minus ) are the eigenvectors.
The shortcut
For :
Example: has trace 5 and determinant , so . The eigenvalues are 2 and 3.
A example in SymPy
Let . SymPy computes the characteristic polynomial, its roots with multiplicities, and the eigenvectors, all exactly:
from sympy import Matrix, symbols, factor, eye
lam = symbols("lambda")
A = Matrix([[4, 1, 1], [1, 4, 1], [1, 1, 4]])
p = (A - lam * eye(3)).det()
print("det(A - lambda I) =", factor(p))
print("eigenvalues {value: multiplicity}:", A.eigenvals())
for value, mult, vecs in A.eigenvects():
print(f"lambda = {value}: basis of eigenspace", [list(v) for v in vecs])det(A - lambda I) = -(lambda - 6)*(lambda - 3)**2
eigenvalues {value: multiplicity}: {6: 1, 3: 2}
lambda = 3: basis of eigenspace [[-1, 1, 0], [-1, 0, 1]]
lambda = 6: basis of eigenspace [[1, 1, 1]]
The polynomial is , so appears once and twice. The number of times a root repeats is its algebraic multiplicity. The dimension of the eigenspace is its geometric multiplicity. Here has a two-dimensional eigenspace: and are independent, and every vector whose entries add up to 0 is an eigenvector. The geometric multiplicity is always between 1 and the algebraic multiplicity, and when it is smaller the matrix cannot be diagonalized (Diagonalization).
Shortcuts worth knowing
| Matrix | Eigenvalues |
|---|---|
| triangular (upper or lower), or diagonal | the diagonal entries |
| roots of | |
| singular () | 0 is one of them |
| any | they add up to and multiply to (counted with multiplicity) |
The triangular rule works because is again triangular, and the determinant of a triangular matrix is the product of its diagonal (The Determinant of a Triangular Matrix): .
How computers really do it
For large nobody computes the characteristic polynomial. Its coefficients are very sensitive to rounding, and there is no formula for the roots of a polynomial of degree 5 or more. Numerical libraries (LAPACK, behind numpy.linalg.eig) use iterative methods, mainly the QR algorithm, which converges to a triangular matrix with the eigenvalues on the diagonal.
import numpy as np
A = np.array([[4.0, -2.0], [1.0, 1.0]])
values, vectors = np.linalg.eig(A)
for i in range(2):
v = vectors[:, i]
print(f"lambda = {float(values[i]):.4f}, unit eigenvector = ({v[0]:.4f}, {v[1]:.4f})")
print(" A v - lambda v =", np.round(A @ v - values[i] * v, 12) + 0.0)lambda = 3.0000, unit eigenvector = (0.8944, 0.4472)
A v - lambda v = [0. 0.]
lambda = 2.0000, unit eigenvector = (0.7071, 0.7071)
A v - lambda v = [0. 0.]
NumPy normalises each eigenvector to length 1, so appears as and as . The sign and order are up to the library. For symmetric matrices use np.linalg.eigh, which is faster, returns sorted real eigenvalues and orthonormal eigenvectors.
Tip: Eigenvectors are only defined up to a nonzero factor. When comparing your hand answer with a library, check the direction (is one a multiple of the other?), not the exact numbers.
Exercises
Exercise 1: A by hand
Find the eigenvalues and eigenvectors of .
Answer
with , and with .
Solution
Exercise 2: Read them off
What are the eigenvalues of ? What are their algebraic multiplicities?
Answer
7 (algebraic multiplicity 2) and −2 (multiplicity 1).
Solution
The matrix is upper triangular, so . Check: the eigenvalues add up to .
Exercise 3: A block matrix
Find the eigenvalues of and one eigenvector for each.
Answer
: ; : ; : .
Solution
Expanding along the last row gives . The upper-left block is the matrix from Eigenvectors and Eigenvalues, and is left alone except for the factor 7.
from sympy import Matrix
B = Matrix([[2, 1, 0], [1, 2, 0], [0, 0, 7]])
for value, mult, vecs in B.eigenvects():
print(value, mult, [list(v) for v in vecs])1 1 [[-1, 1, 0]]
3 1 [[1, 1, 0]]
7 1 [[0, 0, 1]]
Exercise 4: Trace and determinant check
A matrix has trace 1 and determinant −12. Find its eigenvalues without knowing the matrix, then check your answer on , which has that trace and determinant.
Answer
and .
Solution
import numpy as np
M = np.array([[3.0, 3.0], [2.0, -2.0]])
print(sorted(round(float(x), 6) for x in np.linalg.eigvals(M)))[-3.0, 4.0]
Test yourself
Why are the eigenvalues the roots of ?
- Because the determinant is linear in
- Because has a nonzero solution exactly when is singular
- Because is always invertible
- Because eigenvectors have length 1
What is the characteristic polynomial of a matrix with trace 6 and determinant 8?
is a double root of the characteristic polynomial, and its eigenspace is a line. What are its algebraic and geometric multiplicities?
- 2 and 2
- 1 and 2
- 2 and 1
- 3 and 1