If you take a square matrix M, subtract x from the elements on the diagonal, and take the determinant, you get a polynomial in x called the characteristic polynomial of M. For example, let
The characteristic equation is the equation that sets the characteristic polynomial to zero. The roots of this polynomial are eigenvalues of the matrix.
The Cayley-Hamilton theorem says that if you take the original matrix and stick it into the polynomial, you’ll get the zero matrix.
In brief, a matrix satisfies its own characteristic equation. Note that for this to hold we interpret constants, like 12 and 0, as corresponding multiples of the identity matrix.
You could verify the Cayley-Hamilton theorem in Python using
scipy.linalg.funm to compute a polynomial function of a matrix.
>>> from scipy import array >>> from scipy.linalg import funm >>> m = array([[5, -2], [1, 2]]) >>> funm(m, lambda x: x**2 - 7*x + 12)
This returns a zero matrix.
funm is factoring M into something like PDP-1 where D is a diagonal matrix. Then
f(M) = P f(D) P-1.
This is because f can be applied to a diagonal matrix by simply applying f to each diagonal entry independently. You could use this to prove the Cayley-Hamilton theorem for diagonalizable matrices.