The Cayley-Hamilton Theorem
Every square matrix satisfies its own characteristic polynomial: plug the matrix into and you get the zero matrix. This surprising fact means that any power of an matrix, and its inverse, can be written using only .
The statement
Let be the characteristic polynomial of the matrix (Finding Eigenvalues). Replace by and the constant by :
For a matrix, , so
Take , with trace 5 and determinant . The theorem says :
python · try it yourselffrom sympy import Matrix, symbols, eye, zeros
lam = symbols("lambda")
A = Matrix([[2, 0, 1], [1, 3, -1], [0, 1, 1]])
p = A.charpoly(lam) # SymPy uses det(lambda*I - A), monic
print("p(lambda) =", p.as_expr())
coeffs = p.all_coeffs() # highest power first
n = A.shape[0]
pA = zeros(n, n)
for power, c in zip(range(n, -1, -1), coeffs):
pA += c * A**power
print("p(A) =", pA.tolist())
p(lambda) = lambda**3 - 6*lambda**2 + 12*lambda - 9
p(A) = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
SymPy's charpoly uses , which is : same roots, and either way.
Why it is true (a sketch)
For diagonalizable matrices it is quick. If then , and because every is a root of .
In general, the diagonalizable matrices are "dense": any matrix is a limit of matrices with distinct eigenvalues (perturb the diagonal slightly), and both sides of depend continuously on the entries. A purely algebraic proof uses the adjugate identity and compares coefficients of .
Note: The tempting one-line proof "" is wrong. In , is a scalar; substituting a matrix inside the determinant gives the number 0, while is a matrix. The theorem needs a real argument.
Use 1: the inverse as a polynomial in
Rearrange to isolate . For matrices with :
For : , the familiar "swap the diagonal, negate the rest, divide by the determinant" rule (Application: A Formula for the Inverse). In dimensions the same rearrangement writes as a polynomial of degree in , with coefficients from the characteristic polynomial.
Use 2: high powers collapse
Since is a combination of lower powers, so is every higher power. Concretely, divide by : with . Substituting kills the first term:
python · try it yourselffrom sympy import Matrix, symbols, rem, eye, Poly
lam = symbols("lambda")
A = Matrix([[1, 2], [3, 4]])
p = A.charpoly(lam).as_expr() # lambda**2 - 5*lambda - 2
r = Poly(rem(lam**10, p, lam), lam)
print("remainder of lambda^10 mod p:", r.as_expr())
b, a = r.all_coeffs() # r = b*lambda + a
print("b*A + a*I == A**10:", b * A + a * eye(2) == A**10)
print("A**10 =", (A**10).tolist())
remainder of lambda^10 mod p: 3486025*lambda + 1297782
b*A + a*I == A**10: True
A**10 = [[4783807, 6972050], [10458075, 15241882]]
So is determined by two numbers, the remainder's coefficients. The same idea speeds up linear-recurrence computations: the -th term of a recurrence of order needs only polynomial arithmetic modulo the characteristic polynomial, operations instead of for matrix powers.
The minimal polynomial
is one polynomial that kills , but sometimes a smaller one does. The minimal polynomial is the monic polynomial of least degree with . It divides , and is diagonalizable exactly when has no repeated roots. For the identity (), but .
In software
- Fast linear recurrences: competitive-programming "Kitamasa" and polynomial-based methods for huge- terms rest on Cayley–Hamilton.
- Matrix functions: , or for a small matrix can be written as with , which libraries use for and closed forms (rotations, spring steps).
- Krylov methods: iterative solvers like conjugate gradient and GMRES look for solutions in . Cayley–Hamilton guarantees that span stops growing after at most steps and contains .
Exercises
Exercise 1: Verify for a matrix
For , write the Cayley–Hamilton equation and check it.
Answer
, since .
Solution
Exercise 2: Inverse and cube
For the same , use the theorem to write and as combinations of and .
Answer
; .
Solution
Exercise 3: A matrix of order 4
A matrix has trace 0 and determinant 1. Show that and . Give an example.
Answer
Cayley–Hamilton gives , so and . Example: the rotation .
Solution
Another example is (trace 0, ): not a rotation, yet applying it four times still gives the identity.
Exercise 4: A power by remainder
For , compute as with of degree at most 2, and confirm it in SymPy.
Answer
, the remainder is , so .
Solution
is a companion matrix: its last row says , so . The remainder agrees with at the three roots (there with ):
python · try it yourselffrom sympy import Matrix, symbols, rem, eye
lam = symbols("lambda")
A = Matrix([[0, 1, 0], [0, 0, 1], [2, -1, 2]])
p = A.charpoly(lam).as_expr()
print("p =", p, " remainder:", rem(lam**8, p, lam))
print("51A^2 + 52I == A^8:", 51 * A**2 + 52 * eye(3) == A**8)
print("A^8 =", (A**8).tolist())
p = lambda**3 - 2*lambda**2 + lambda - 2 remainder: 51*lambda**2 + 52
51A^2 + 52I == A^8: True
A^8 = [[52, 0, 51], [102, 1, 102], [204, 0, 205]]
Test yourself
What does the Cayley–Hamilton theorem say?
- Every matrix is diagonalizable
- A matrix satisfies its own characteristic polynomial:
- is the sum of the eigenvalues
A matrix has trace 4 and determinant 3. Which identity holds?
Why is '' not a valid proof?
- Because is not 0
- Because the in is a scalar; that substitution gives the number 0, not the matrix
- Because
- It is a valid proof