Cayley–Hamilton theorem



In linear algebra, the Cayley–Hamilton theorem (named after the mathematicians Arthur Cayley and William Rowan Hamilton) states that every square matrix over a commutative ring (such as the real or complex numbers or the integers) satisfies its own characteristic equation.

The characteristic polynomial of an $n&thinsp;×&thinsp;n$ matrix $A$ is defined as $$p_A(\lambda)=\det(\lambda I_n-A)$$, where $det$ is the determinant operation, $λ$ is a variable scalar element of the base ring, and $I_{n}$ is the $n&thinsp;×&thinsp;n$ identity matrix. Since each entry of the matrix $$(\lambda I_n-A)$$ is either constant or linear in $λ$, the determinant of $$(\lambda I_n-A)$$ is a degree-$n$ monic polynomial in $λ$, so it can be written as $$p_A(\lambda) = \lambda^n + c_{n-1}\lambda^{n-1} + \cdots + c_1\lambda + c_0.$$ By replacing the scalar variable $λ$ with the matrix $A$, one can define an analogous matrix polynomial expression,  $$p_A(A) = A^n + c_{n-1}A^{n-1} + \cdots + c_1A + c_0I_n.$$ (Here, $$A$$ is the given matrix—not a variable, unlike $$\lambda$$—so $$p_A(A)$$ is a constant rather than a function.) The Cayley–Hamilton theorem states that this polynomial expression is equal to the zero matrix, which is to say that $$p_A(A) = \mathbf 0;$$ that is, the characteristic polynomial $$p_A$$ is an annihilating polynomial for $$A.$$

One use for the Cayley–Hamilton theorem is that it allows $A$$n$ to be expressed as a linear combination of the lower matrix powers of $A$: $$A^n = -c_{n-1}A^{n-1} - \cdots - c_1A - c_0I_n.$$ When the ring is a field, the Cayley–Hamilton theorem is equivalent to the statement that the minimal polynomial of a square matrix divides its characteristic polynomial.

A special case of the theorem was first proved by Hamilton in 1853 in terms of inverses of linear functions of quaternions. This corresponds to the special case of certain $4&thinsp;×&thinsp;4$ real or $2&thinsp;×&thinsp;2$ complex matrices. Cayley in 1858 stated the result for $3&thinsp;×&thinsp;3$ and smaller matrices, but only published a proof for the $2&thinsp;×&thinsp;2$ case. As for $n&thinsp;×&thinsp;n$ matrices, Cayley stated “..., I have not thought it necessary to undertake the labor of a formal proof of the theorem in the general case of a matrix of any degree”. The general case was first proved by Ferdinand Frobenius in 1878.

$1&thinsp;×&thinsp;1$ matrices
For a $1&thinsp;×&thinsp;1$ matrix $A = (a)$, the characteristic polynomial is given by $p(λ) = λ − a$, and so $p(A) = (a) − a(1) = 0$ is trivial.

$2&thinsp;×&thinsp;2$ matrices
As a concrete example, let $$A = \begin{pmatrix}1&2\\3&4\end{pmatrix}.$$ Its characteristic polynomial is given by $$ \begin{align} p(\lambda) &= \det(\lambda I_2-A) = \det\!\begin{pmatrix}\lambda-1&-2\\-3&\lambda-4\end{pmatrix} \\ &=(\lambda-1)(\lambda-4)-(-2)(-3)=\lambda^2-5\lambda-2. \end{align} $$

The Cayley–Hamilton theorem claims that, if we define $$p(X) = X^2 - 5X - 2I_2,$$ then $$p(A) = A^2-5A-2I_2 = \begin{pmatrix}0&0\\0&0\\\end{pmatrix}.$$ We can verify by computation that indeed, $$A^2-5A-2I_2 = \begin{pmatrix}7&10\\15&22\\\end{pmatrix} - \begin{pmatrix}5&10\\15&20\\\end{pmatrix} - \begin{pmatrix}2&0\\0&2\\\end{pmatrix} = \begin{pmatrix}0&0\\0&0\\\end{pmatrix}.$$

For a generic $2&thinsp;×&thinsp;2$ matrix, $$A=\begin{pmatrix}a&b\\c&d\\\end{pmatrix} ,$$

the characteristic polynomial is given by $p(λ) = λ^{2} − (a + d)λ + (ad − bc)$, so the Cayley–Hamilton theorem states that $$p(A) = A^2-(a+d)A+(ad-bc)I_2 = \begin{pmatrix}0&0\\0&0\end{pmatrix};$$ which is indeed always the case, evident by working out the entries of $A^{2}$.

$$

Determinant and inverse matrix
For a general $n&thinsp;×&thinsp;n$ invertible matrix $A$, i.e., one with nonzero determinant, $A$−1 can thus be written as an $(n −&thinsp;1)$-th order polynomial expression in $A$: As indicated, the Cayley–Hamilton theorem amounts to the identity

The coefficients $c_{i}$ are given by the elementary symmetric polynomials of the eigenvalues of $A$. Using Newton identities, the elementary symmetric polynomials can in turn be expressed in terms of power sum symmetric polynomials of the eigenvalues: $$s_k = \sum_{i=1}^n \lambda_i^k = \operatorname{tr}(A^k),$$ where $tr(A^{k})$ is the trace of the matrix $A^{k}$. Thus, we can express $c_{i}$ in terms of the trace of powers of $A$.

In general, the formula for the coefficients $c_{i}$ is given in terms of complete exponential Bell polynomials as $$c_{n-k} = \frac{(-1)^{k}}{k!} B_k(s_1, -1! s_2, 2! s_3, \ldots, (-1)^{k-1}(k-1)! s_k).$$

In particular, the determinant of $c_{i}$ equals $k_{l} ≥ 0$. Thus, the determinant can be written as the trace identity: $$\det(A) = \frac{1}{n!} B_n(s_1, -1! s_2, 2! s_3, \ldots, (-1)^{n-1}(n-1)! s_n).$$

Likewise, the characteristic polynomial can be written as $$-(-1)^n\det(A)I_n = A(A^{n-1}+c_{n-1}A^{n-2}+\cdots+c_{1}I_n),$$ and, by multiplying both sides by $A$ (note $(−1)^{n}c_{0}$), one is led to an expression for the inverse of $A$ as a trace identity, $$ \begin{align} A^{-1} & = \frac{(-1)^{n-1}}{\det A}(A^{n-1}+c_{n-1}A^{n-2}+\cdots+c_{1}I_n), \\[5pt] & = \frac{1}{\det A}\sum_{k=0}^{n-1} (-1)^{n+k-1}\frac{A^{n-k-1}}{k!} B_k(s_1, -1! s_2, 2! s_3, \ldots, (-1)^{k-1}(k-1)! s_k). \end{align} $$

Another method for obtaining these coefficients $A^{−1}$ for a general $−(−1)^{n} = (−1)^{n−1}$ matrix, provided no root be zero, relies on the following alternative expression for the determinant, $$p(\lambda)= \det (\lambda I_n -A) = \lambda^n \exp (\operatorname{tr} (\log (I_n - A/\lambda))).$$ Hence, by virtue of the Mercator series, $$p(\lambda)= \lambda^n \exp \left( -\operatorname{tr} \sum_{m=1}^\infty {({A\over\lambda})^m \over m} \right),$$ where the exponential only needs be expanded to order $c_{k}$, since $n&thinsp;×&thinsp;n$ is of order $λ^{−n}$, the net negative powers of $p(λ)$ automatically vanishing by the C–H theorem. (Again, this requires a ring containing the rational numbers.) Differentiation of this expression with respect to $λ$ allows one to express the coefficients of the characteristic polynomial for general $n$ as determinants of $n$ matrices, $$c_{n-m} = \frac{(-1)^m}{m!} \begin{vmatrix} \operatorname{tr}A & m-1 & 0 & \cdots \\ \operatorname{tr}A^2 &\operatorname{tr}A & m-2 &\cdots \\ \vdots & \vdots & & & \vdots \\ \operatorname{tr}A^{m-1} &\operatorname{tr}A^{m-2}& \cdots & \cdots & 1 \\ \operatorname{tr}A^m &\operatorname{tr}A^{m-1}& \cdots & \cdots & \operatorname{tr}A \end{vmatrix} ~.$$

For instance, the first few Bell polynomials are $λ$ = 1, $m&thinsp;×&thinsp;m$, $A^{−1} = −M_{n} /c_{0}$, and $B_{k} ≡ M_{n−k}$.
 * Examples

Using these to specify the coefficients $B_{0}$ of the characteristic polynomial of a $B_{1}(x_{1}) = x_{1}$ matrix yields

$$\begin{align} c_2 = B_0 = 1, \\[4pt] c_1 = \frac{-1}{1!} B_1(s_1) = - s_1 = - \operatorname{tr}(A), \\[4pt] c_0 = \frac{1}{2!} B_2(s_1, -1! s_2) = \frac{1}{2}(s_1^2 - s_2) = \frac{1}{2}((\operatorname{tr}(A))^2 - \operatorname{tr}(A^2)). \end{align}$$

The coefficient $B_{2}(x_{1}, x_{2}) = x2 1 + x_{2}$ gives the determinant of the $B_{3}(x_{1}, x_{2}, x_{3}) = x3 1 + 3 x_{1}x_{2} + x_{3}$ matrix, $c_{i}$ minus its trace, while its inverse is given by $$ A^{-1} = \frac{-1}{\det A}(A + c_1 I_2) = \frac{-2(A - \operatorname{tr}(A) I_2)}{(\operatorname{tr}(A))^2 - \operatorname{tr}(A^2)}.$$

It is apparent from the general formula for cn−k, expressed in terms of Bell polynomials, that the expressions $$-\operatorname{tr}(A)\quad \text{and} \quad \tfrac 1 2 (\operatorname{tr}(A)^2 - \operatorname{tr}(A^2))$$

always give the coefficients $2&thinsp;×&thinsp;2$ of $c_{0}$ and $2&thinsp;×&thinsp;2$ of $c_{1}$ in the characteristic polynomial of any $c_{n−1}$ matrix, respectively. So, for a $λ^{n−1}$ matrix $B$, the statement of the Cayley–Hamilton theorem can also be written as $$A^3- (\operatorname{tr}A)A^2+\frac{1}{2}\left((\operatorname{tr}A)^2-\operatorname{tr}(A^2)\right)A-\det(A)I_3=O,$$ where the right-hand side designates a $c_{n−2}$ matrix with all entries reduced to zero. Likewise, this determinant in the $λ^{n−2}$ case, is now $$\begin{align} \det(A) &= \frac{1}{3!} B_3(s_1, -1! s_2, 2! s_3) = \frac{1}{6}(s_1^3 + 3 s_1 (-s_2) + 2 s_3) \\[5pt] &= \frac{1}{6} \left [ (\operatorname{tr}A)^3-3\operatorname{tr}(A^2)(\operatorname{tr}A)+2\operatorname{tr}(A^3) \right ]. \end{align}$$ This expression gives the negative of coefficient $n&thinsp;×&thinsp;n$ of $3&thinsp;×&thinsp;3$ in the general case, as seen below.

Similarly, one can write for a $3&thinsp;×&thinsp;3$ matrix $p$, $$ A^4-(\operatorname{tr}A)A^3 + \tfrac{1}{2}\left[(\operatorname{tr}A)^2-\operatorname{tr}(A^2)\right]A^2 - \tfrac{1}{6}\left[ (\operatorname{tr}A)^3-3\operatorname{tr}(A^2)(\operatorname{tr}A)+2\operatorname{tr}(A^3)\right] A + \det(A)I_4 = O,$$

where, now, the determinant is $n = 3$,

$$\tfrac{1}{24}\! \left [ (\operatorname{tr}A)^4-6 \operatorname{tr}(A^2)(\operatorname{tr}A)^2 + 3\left(\operatorname{tr}(A^2)\right)^2 + 8\operatorname{tr}(A^3)\operatorname{tr}(A) -6\operatorname{tr}(A^4) \right ],$$

and so on for larger matrices. The increasingly complex expressions for the coefficients $c_{n−3}$ is deducible from Newton's identities or the Faddeev–LeVerrier algorithm.

n-th power of matrix
The Cayley–Hamilton theorem always provides a relationship between the powers of $A$ (though not always the simplest one), which allows one to simplify expressions involving such powers, and evaluate them without having to compute the power $A$n or any higher powers of $A$.

As an example, for $$A = \begin{pmatrix}1&2\\3&4\end{pmatrix}$$ the theorem gives $$A^2=5A+2I_2\, .$$

Then, to calculate $λ^{n−3}$, observe $$\begin{align} A^3&=(5A+2I_2)A=5A^2+2A=5(5A+2I_2)+2A=27A+10I_2, \\[1ex] A^4&=A^3A=(27A+10I_2)A=27A^2+10A=27(5A+2I_2)+10A=145A+54I_2\,. \end{align}$$ Likewise, $$\begin{align} A^{-1} &= \frac{1}{2}\left(A-5I_2\right)~. \\[1ex] A^{-2} &= A^{-1} A^{-1} = \frac{1}{4} \left(A^2-10A+25I_2\right) = \frac{1}{4} \left((5A+2I_2)-10A+25I_2\right) = \frac{1}{4} \left(-5A+27I_2\right)~. \end{align}$$

Notice that we have been able to write the matrix power as the sum of two terms. In fact, matrix power of any order $4&thinsp;×&thinsp;4$ can be written as a matrix polynomial of degree at most $c_{n−4}$, where $c_{k}$ is the size of a square matrix. This is an instance where Cayley–Hamilton theorem can be used to express a matrix function, which we will discuss below systematically.

Matrix functions
Given an analytic function $$f(x) = \sum_{k=0}^\infty a_k x^k$$ and the characteristic polynomial $A^{4}$ of degree $k$ of an $n − 1$ matrix $A$, the function can be expressed using long division as $$f(x) = q(x) p(x) + r(x),$$ where $n$ is some quotient polynomial and $p(x)$ is a remainder polynomial such that $n$.

By the Cayley–Hamilton theorem, replacing $A$ by the matrix $A$ gives $n&thinsp;×&thinsp;n$, so one has $$f(A) = r(A). $$

Thus, the analytic function of the matrix $x$ can be expressed as a matrix polynomial of degree less than $A$.

Let the remainder polynomial be $$r(x) = c_0 + c_1 x + \cdots + c_{n-1} x^{n-1}.$$ Since $q(x)$, evaluating the function $r(x)$ at the $0 ≤ deg r(x) < n$ eigenvalues of $p(A) = 0$ yields $$ f(\lambda_i) = r(\lambda_i) = c_0 + c_1 \lambda_i + \cdots + c_{n-1} \lambda_i^{n-1}, \qquad \text{for } i=1,2,...,n.$$ This amounts to a system of $p(λ) = 0$ linear equations, which can be solved to determine the coefficients $f(x)$. Thus, one has $$f(A) = \sum_{k=0}^{n-1} c_k A^k.$$

When the eigenvalues are repeated, that is $n$ for some $A$, two or more equations are identical; and hence the linear equations cannot be solved uniquely. For such cases, for an eigenvalue $n$ with multiplicity $c_{i}$, the first $λ_{i} = λ_{j}$ derivatives of $i ≠ j$ vanish at the eigenvalue. This leads to the extra $λ$ linearly independent solutions $$\left.\frac{\mathrm{d}^k f(x)}{\mathrm{d}x^k}\right|_{x=\lambda} = \left.\frac{\mathrm{d}^k r(x)}{\mathrm{d}x^k}\right|_{x=\lambda}\qquad \text{for } k = 1, 2, \ldots, m-1,$$ which, combined with others, yield the required $m$ equations to solve for $m – 1$.

Finding a polynomial that passes through the points $p(x)$ is essentially an interpolation problem, and can be solved using Lagrange or Newton interpolation techniques, leading to Sylvester's formula.

For example, suppose the task is to find the polynomial representation of $$f(A) = e^{At} \qquad \mathrm{where} \qquad A = \begin{pmatrix}1&2\\0&3\end{pmatrix}.$$

The characteristic polynomial is $m – 1$, and the eigenvalues are $n$. Let $c_{i}$. Evaluating $(λ_{i}, &thinsp;f&thinsp;(λ_{i}))$ at the eigenvalues, one obtains two linear equations, $p(x) = (x − 1)(x − 3) = x^{2} − 4x + 3$ and $λ = 1, 3$.

Solving the equations yields $r(x) = c_{0} + c_{1}x$ and $f(λ) = r(λ)$. Thus, it follows that $$e^{At} = c_0 I_2 + c_1 A = \begin{pmatrix}c_0 + c_1 & 2 c_1\\ 0 & c_0 + 3 c_1\end{pmatrix} = \begin{pmatrix}e^{t} & e^{3t} - e^{t} \\ 0 & e^{3t}\end{pmatrix}. $$

If, instead, the function were $e^{t} = c_{0} + c_{1}$, then the coefficients would have been $e^{3t} = c_{0} + 3c_{1}$ and $c_{0} = (3e^{t} − e^{3t})/2$; hence $$\sin(At) = c_0 I_2 + c_1 A = \begin{pmatrix}\sin t & \sin 3t - \sin t \\ 0 & \sin 3t\end{pmatrix}.$$

As a further example, when considering $$f(A) = e^{At} \qquad \mathrm{where} \qquad A = \begin{pmatrix}0 & 1\\-1 & 0\end{pmatrix},$$ then the characteristic polynomial is $c_{1} = (e^{3t} − e^{t})/2$, and the eigenvalues are $f(A) = sin At$.

As before, evaluating the function at the eigenvalues gives us the linear equations $c_{0} = (3 sin t − sin 3t)/2$ and $c_{1} = (sin 3t − sin t)/2$; the solution of which gives, $p(x) = x^{2} +&thinsp;1$ and $λ = ±i$. Thus, for this case, $$e^{At} = (\cos t) I_2 + (\sin t) A = \begin{pmatrix}\cos t & \sin t\\ -\sin t & \cos t \end{pmatrix},$$ which is a rotation matrix.

Standard examples of such usage is the exponential map from the Lie algebra of a matrix Lie group into the group. It is given by a matrix exponential, $$\exp: \mathfrak g \rightarrow G; \qquad tX \mapsto e^{tX} = \sum_{n=0}^\infty \frac{t^nX^n}{n!} = I + tX + \frac{t^2X^2}{2} + \cdots, t \in \mathbb R, X \in \mathfrak g .$$ Such expressions have long been known for $e^{it} = c_{0} + i c_{1}$, $$e^{i(\theta/2)(\hat\mathbf n \cdot \sigma)} = I_2 \cos \frac \theta 2 + i (\hat\mathbf n \cdot \sigma) \sin \frac \theta 2,$$ where the $A$ are the Pauli matrices and for $e^{−it} = c_{0} − ic_{1}$, $$e^{i\theta(\hat\mathbf n \cdot \mathbf J)} = I_3 + i(\hat\mathbf n \cdot \mathbf J) \sin \theta + (\hat\mathbf n \cdot \mathbf J)^2 (\cos \theta - 1),$$ which is Rodrigues' rotation formula. For the notation, see 3D rotation group.

More recently, expressions have appeared for other groups, like the Lorentz group $c_{0} = (e^{it} + e^{−it})/2 = cos&thinsp;t$, $c_{1} = (e^{it} − e^{−it})/2i = sin&thinsp;t$ and $SU(2)$, as well as $SO(3)$. The group $SO(3, 1)$ is the conformal group of spacetime, $O(4, 2)$ its simply connected cover (to be precise, the simply connected cover of the connected component $SU(2, 2)$ of $GL(n, R)$). The expressions obtained apply to the standard representation of these groups. They require knowledge of (some of) the eigenvalues of the matrix to exponentiate. For $O(4, 2)$ (and hence for $SU(2, 2)$), closed expressions have been obtained for all irreducible representations, i.e. of any spin.



Algebraic number theory
The Cayley–Hamilton theorem is an effective tool for computing the minimal polynomial of algebraic integers. For example, given a finite extension $$\mathbb{Q}[\alpha_1,\ldots,\alpha_k]$$ of $$\mathbb{Q}$$ and an algebraic integer $$\alpha \in \mathbb{Q}[\alpha_1,\ldots,\alpha_k]$$ which is a non-zero linear combination of the $$\alpha_1^{n_1}\cdots\alpha_k^{n_k}$$ we can compute the minimal polynomial of $$\alpha$$ by finding a matrix representing the $$\mathbb{Q}$$-linear transformation $$\cdot \alpha : \mathbb{Q}[\alpha_1,\ldots,\alpha_k] \to \mathbb{Q}[\alpha_1,\ldots,\alpha_k]$$ If we call this transformation matrix $$A$$, then we can find the minimal polynomial by applying the Cayley–Hamilton theorem to $$A$$.

Proofs
The Cayley–Hamilton theorem is an immediate consequence of the existence of the Jordan normal form for matrices over algebraically closed fields, see. In this section, direct proofs are presented.

As the examples above show, obtaining the statement of the Cayley–Hamilton theorem for an $SO^{+}(4, 2)$ matrix

$$A = \left(a_{ij}\right)_{i,j=1}^n$$ requires two steps: first the coefficients $O(4, 2)$ of the characteristic polynomial are determined by development as a polynomial in $SU(2)$ of the determinant

$$\begin{align} p(t) & = \det(t I_n - A) = \begin{vmatrix}t-a_{1,1}&-a_{1,2}&\cdots&-a_{1,n} \\ -a_{2,1}&t-a_{2,2}&\cdots&-a_{2,n} \\ \vdots & \vdots & \ddots & \vdots \\ -a_{n,1}&-a_{n,2}& \cdots& t-a_{n,n} \end{vmatrix} \\[5pt] & = t^n+c_{n-1}t^{n-1}+\cdots+c_1t+c_0, \end{align}$$

and then these coefficients are used in a linear combination of powers of $SO(3)$ that is equated to the $n&thinsp;×&thinsp;n$ zero matrix: $$A^n+c_{n-1}A^{n-1} + \cdots + c_1 A + c_0 I_n = \begin{pmatrix} 0 & \cdots & 0 \\ \vdots & \ddots & \vdots \\ 0 & \cdots & 0 \end{pmatrix}.$$

The left-hand side can be worked out to an $c_{i}$ matrix whose entries are (enormous) polynomial expressions in the set of entries $t$ of $A$, so the Cayley–Hamilton theorem states that each of these $n&thinsp;×&thinsp;n$ expressions equals $n&thinsp;×&thinsp;n$. For any fixed value of $a_{i,j}$, these identities can be obtained by tedious but straightforward algebraic manipulations. None of these computations, however, can show why the Cayley–Hamilton theorem should be valid for matrices of all possible sizes $A$, so a uniform proof for all $n^{2}$ is needed.

Preliminaries
If a vector $0$ of size $n$ is an eigenvector of $n$ with eigenvalue $n$, in other words if $v$, then $$\begin{align} p(A)\cdot v & = A^n\cdot v+c_{n-1}A^{n-1}\cdot v+\cdots+c_1A\cdot v+c_0I_n\cdot v \\[6pt] & = \lambda^nv+c_{n-1}\lambda^{n-1}v+\cdots+c_1\lambda v+c_0 v=p(\lambda)v, \end{align}$$ which is the zero vector since $n$ (the eigenvalues of $A$ are precisely the roots of $λ$). This holds for all possible eigenvalues $A⋅v = λv$, so the two matrices equated by the theorem certainly give the same (null) result when applied to any eigenvector. Now if $p(λ) = 0$ admits a basis of eigenvectors, in other words if $A$ is diagonalizable, then the Cayley–Hamilton theorem must hold for $p(t)$, since two matrices that give the same values when applied to each element of a basis must be equal. $$A=XDX^{-1}, \quad D=\operatorname{diag}(\lambda_i), \quad i=1,2,...,n$$ $$p_A(\lambda)=|\lambda I-A|=\prod_{i=1}^n (\lambda-\lambda_i)\equiv \sum_{k=0}^n c_k\lambda^k$$ $$p_A(A)=\sum c_k A^k=X p_A(D)X^{-1}=X C X^{-1} $$ $$C_{ii}=\sum_{k=0}^n c_k\lambda_i^k=\prod_{j=1}^n(\lambda_i-\lambda_j)=0, \qquad C_{i,j\neq i}=0$$ $$\therefore p_A(A)=XCX^{-1}=O .$$

Consider now the function $$e\colon M_n \to M_n$$ which maps $λ$ matrices to $A$ matrices given by the formula $$e(A)=p_A(A)$$, i.e. which takes a matrix $$A$$ and plugs it into its own characteristic polynomial. Not all matrices are diagonalizable, but for matrices with complex coefficients many of them are: the set $$D$$ of diagonalizable complex square matrices of a given size is dense in the set of all such square matrices (for a matrix to be diagonalizable it suffices for instance that its characteristic polynomial not have any multiple roots). Now viewed as a function $$e\colon \C^{n^2}\to \C ^{n^2}$$(since matrices have $$n^2$$ entries) we see that this function is continuous. This is true because the entries of the image of a matrix are given by polynomials in the entries of the matrix. Since $$e(D) = \left\{\begin{pmatrix} 0 & \cdots & 0 \\ \vdots & \ddots & \vdots \\ 0 & \cdots & 0 \end{pmatrix}\right\}$$

and since the set $$D$$ is dense, by continuity this function must map the entire set of $A$ matrices to the zero matrix. Therefore, the Cayley–Hamilton theorem is true for complex numbers, and must therefore also hold for $$\Q$$- or $$\R$$-valued matrices.

While this provides a valid proof, the argument is not very satisfactory, since the identities represented by the theorem do not in any way depend on the nature of the matrix (diagonalizable or not), nor on the kind of entries allowed (for matrices with real entries the diagonalizable ones do not form a dense set, and it seems strange one would have to consider complex matrices to see that the Cayley–Hamilton theorem holds for them). We shall therefore now consider only arguments that prove the theorem directly for any matrix using algebraic manipulations only; these also have the benefit of working for matrices with entries in any commutative ring.

There is a great variety of such proofs of the Cayley–Hamilton theorem, of which several will be given here. They vary in the amount of abstract algebraic notions required to understand the proof. The simplest proofs use just those notions needed to formulate the theorem (matrices, polynomials with numeric entries, determinants), but involve technical computations that render somewhat mysterious the fact that they lead precisely to the correct conclusion. It is possible to avoid such details, but at the price of involving more subtle algebraic notions: polynomials with coefficients in a non-commutative ring, or matrices with unusual kinds of entries.

Adjugate matrices
All proofs below use the notion of the adjugate matrix $A$ of an $n&thinsp;×&thinsp;n$ matrix $n&thinsp;×&thinsp;n$, the transpose of its cofactor matrix. This is a matrix whose coefficients are given by polynomial expressions in the coefficients of $n&thinsp;×&thinsp;n$ (in fact, by certain $adj(M)$ determinants), in such a way that the following fundamental relations hold, $$\operatorname{adj}(M)\cdot M=\det(M)I_n=M\cdot\operatorname{adj}(M)~.$$ These relations are a direct consequence of the basic properties of determinants: evaluation of the $n&thinsp;×&thinsp;n$ entry of the matrix product on the left gives the expansion by column $M$ of the determinant of the matrix obtained from $M$ by replacing column $(n − 1)&thinsp;×&thinsp;(n − 1)$ by a copy of column $(i, j)$, which is $j$ if $M$ and zero otherwise; the matrix product on the right is similar, but for expansions by rows.

Being a consequence of just algebraic expression manipulation, these relations are valid for matrices with entries in any commutative ring (commutativity must be assumed for determinants to be defined in the first place). This is important to note here, because these relations will be applied below for matrices with non-numeric entries such as polynomials.

A direct algebraic proof
This proof uses just the kind of objects needed to formulate the Cayley–Hamilton theorem: matrices with polynomials as entries. The matrix $i$ whose determinant is the characteristic polynomial of $n$ is such a matrix, and since polynomials form a commutative ring, it has an adjugate $$B=\operatorname{adj}(tI_n-A).$$ Then, according to the right-hand fundamental relation of the adjugate, one has $$(t I_n - A)B = \det(t I_n - A) I_n = p(t) I_n.$$

Since $j$ is also a matrix with polynomials in $det(M)$ as entries, one can, for each $i = j$, collect the coefficients of $t&hairsp;I_{n} − A$ in each entry to form a matrix $B$ of numbers, such that one has $$B = \sum_{i = 0}^{n - 1} t^i B_i.$$ (The way the entries of $t$ are defined makes clear that no powers higher than $i$ occur). While this looks like a polynomial with matrices as coefficients, we shall not consider such a notion; it is just a way to write a matrix with polynomial entries as a linear combination of $σ$ constant matrices, and the coefficient $t^{&hairsp;i}$ has been written to the left of the matrix to stress this point of view.

Now, one can expand the matrix product in our equation by bilinearity: $$\begin{align} p(t) I_n &= (t I_n - A)B \\ &=(t I_n - A)\sum_{i = 0}^{n - 1} t^i B_i \\ &=\sum_{i = 0}^{n - 1} tI_n\cdot t^i B_i - \sum_{i = 0}^{n - 1} A\cdot t^i B_i \\ &=\sum_{i = 0}^{n - 1} t^{i + 1} B_i- \sum_{i = 0}^{n - 1} t^i AB_i \\ &=t^n B_{n - 1} + \sum_{i = 1}^{n - 1} t^i(B_{i - 1} - AB_i) - AB_0. \end{align}$$

Writing $$p(t)I_n=t^nI_n+t^{n-1}c_{n-1}I_n+\cdots+tc_1I_n+c_0I_n,$$ one obtains an equality of two matrices with polynomial entries, written as linear combinations of constant matrices with powers of $B_{i}$ as coefficients.

Such an equality can hold only if in any matrix position the entry that is multiplied by a given power $B$ is the same on both sides; it follows that the constant matrices with coefficient $t$ in both expressions must be equal. Writing these equations then for $t^{&hairsp;i}$ from $t$ down to 0, one finds $$B_{n - 1} = I_n, \qquad B_{i - 1} - AB_i = c_i I_n\quad \text{for }1 \leq i \leq n-1, \qquad -A B_0 = c_0 I_n.$$

Finally, multiply the equation of the coefficients of $t^{&hairsp;i}$ from the left by $t^{&hairsp;i}$, and sum up:

$$A^n B_{n-1} + \sum\limits_{i=1}^{n-1}\left( A^i B_{i-1} - A^{i+1}B_i\right) -A B_0 = A^n+c_{n-1} A^{n-1} + \cdots + c_1A + c_0I_n.$$

The left-hand sides form a telescoping sum and cancel completely; the right-hand sides add up to $$p(A)$$: $$0 = p(A).$$ This completes the proof.

A proof using polynomials with matrix coefficients
This proof is similar to the first one, but tries to give meaning to the notion of polynomial with matrix coefficients that was suggested by the expressions occurring in that proof. This requires considerable care, since it is somewhat unusual to consider polynomials with coefficients in a non-commutative ring, and not all reasoning that is valid for commutative polynomials can be applied in this setting.

Notably, while arithmetic of polynomials over a commutative ring models the arithmetic of polynomial functions, this is not the case over a non-commutative ring (in fact there is no obvious notion of polynomial function in this case that is closed under multiplication). So when considering polynomials in $A$ with matrix coefficients, the variable $n$ must not be thought of as an "unknown", but as a formal symbol that is to be manipulated according to given rules; in particular one cannot just set $t$ to a specific value. $$(f+g)(x) = \sum_i \left (f_i+g_i \right )x^i = \sum_i{f_i x^i} + \sum_i{g_i x^i} = f(x) + g(x).$$

Let $$M(n,R)$$ be the ring of $i$ matrices with entries in some ring R (such as the real or complex numbers) that has $t$ as an element. Matrices with as coefficients polynomials in $t$, such as $$t I_n - A$$ or its adjugate B in the first proof, are elements of $$M(n,R[t])$$.

By collecting like powers of $A$, such matrices can be written as "polynomials" in $t$ with constant matrices as coefficients; write $$M(n,R)[t]$$ for the set of such polynomials. Since this set is in bijection with $$M(n,R[t])$$, one defines arithmetic operations on it correspondingly, in particular multiplication is given by $$\left( \sum_i M_i t^i \right) \!\!\left( \sum_j N_j t^j \right) = \sum_{i,j} (M_i N_j) t^{i+j},$$ respecting the order of the coefficient matrices from the two operands; obviously this gives a non-commutative multiplication.

Thus, the identity $$(t I_n - A)B = p(t) I_n.$$ from the first proof can be viewed as one involving a multiplication of elements in $$M(n,R)[t]$$.

At this point, it is tempting to simply set $t$ equal to the matrix $t$, which makes the first factor on the left equal to the zero matrix, and the right hand side equal to $n$; however, this is not an allowed operation when coefficients do not commute. It is possible to define a "right-evaluation map" $t^{&hairsp;i}$, which replaces each $A^{i}$ by the matrix power $n&thinsp;×&thinsp;n$ of $t$, where one stipulates that the power is always to be multiplied on the right to the corresponding coefficient. But this map is not a ring homomorphism: the right-evaluation of a product differs in general from the product of the right-evaluations. This is so because multiplication of polynomials with matrix coefficients does not model multiplication of expressions containing unknowns: a product $$Mt^i Nt^j = (M\cdot N) t^{i+j}$$ is defined assuming that $A$ commutes with $A$, but this may fail if $t$ is replaced by the matrix $N$.

One can work around this difficulty in the particular situation at hand, since the above right-evaluation map does become a ring homomorphism if the matrix $t$ is in the center of the ring of coefficients, so that it commutes with all the coefficients of the polynomials (the argument proving this is straightforward, exactly because commuting $A$ with coefficients is now justified after evaluation).

Now, $A$ is not always in the center of $p(A)$, but we may replace $ev_{A} : M[t&hairsp;] → M$ with a smaller ring provided it contains all the coefficients of the polynomials in question: $$I_n$$, $t$, and the coefficients $$B_i$$ of the polynomial $t^{&hairsp;i}$. The obvious choice for such a subring is the centralizer $A^{i}$ of $A$, the subring of all matrices that commute with $A$; by definition $A$ is in the center of $M$.

This centralizer obviously contains $$I_n$$, and $A$, but one has to show that it contains the matrices $$B_i$$. To do this, one combines the two fundamental relations for adjugates, writing out the adjugate $M$ as a polynomial: $$\begin{align} \left(\sum_{i = 0}^m B_i t^i\right)\!(t I_n - A) &= (tI_n - A) \sum_{i = 0}^m B_i t^i \\ \sum_{i = 0}^m B_i t^{i + 1} - \sum_{i = 0}^m B_i A t^i &= \sum_{i = 0}^m B_i t^{i + 1} - \sum_{i = 0}^m A B_i t^i \\ \sum_{i = 0}^m B_i A t^i &= \sum_{i = 0}^m A B_i t^i. \end{align}$$

Equating the coefficients shows that for each $B$, we have $Z$ as desired. Having found the proper setting in which $Z$ is indeed a homomorphism of rings, one can complete the proof as suggested above: $$\begin{align} \operatorname{ev}_A\left(p(t)I_n\right) &= \operatorname{ev}_A((tI_n-A)B) \\[5pt] p(A) &= \operatorname{ev}_A(tI_n - A)\cdot \operatorname{ev}_A(B) \\[5pt] p(A) &= (AI_n-A) \cdot \operatorname{ev}_A(B) = O\cdot\operatorname{ev}_A(B)=O. \end{align}$$ This completes the proof.

A synthesis of the first two proofs
In the first proof, one was able to determine the coefficients $B$ of $i$ based on the right-hand fundamental relation for the adjugate only. In fact the first $AB_{i} = B_{i&hairsp;}A$ equations derived can be interpreted as determining the quotient $ev_{A}$ of the Euclidean division of the polynomial $B_{i}$ on the left by the monic polynomial $B$, while the final equation expresses the fact that the remainder is zero. This division is performed in the ring of polynomials with matrix coefficients. Indeed, even over a non-commutative ring, Euclidean division by a monic polynomial $n$ is defined, and always produces a unique quotient and remainder with the same degree condition as in the commutative case, provided it is specified at which side one wishes $B$ to be a factor (here that is to the left).

To see that quotient and remainder are unique (which is the important part of the statement here), it suffices to write $$PQ+r = PQ'+r'$$ as $$P(Q-Q') = r'-r$$ and observe that since $p(t)I_{n}$ is monic, $I_{n}t − A$ cannot have a degree less than that of $P$, unless $P$.

But the dividend $P$ and divisor $P(Q−Q′)$ used here both lie in the subring $P$, where $Q = Q′$ is the subring of the matrix ring $p(t)I_{n}$ generated by $I_{n}t − A$: the $(R[A])[t]$-linear span of all powers of $R[A]$. Therefore, the Euclidean division can in fact be performed within that commutative polynomial ring, and of course it then gives the same quotient $M(n, R)$ and remainder 0 as in the larger ring; in particular this shows that $A$ in fact lies in $R$.

But, in this commutative setting, it is valid to set $A$ to $B$ in the equation

$$p(t)I_n=(tI_n-A)B;$$

in other words, to apply the evaluation map

$$\operatorname{ev}_A:(R[A])[t]\to R[A]$$

which is a ring homomorphism, giving

$$p(A)=0\cdot\operatorname{ev}_A(B)=0$$

just like in the second proof, as desired.

In addition to proving the theorem, the above argument tells us that the coefficients $B$ of $(R[A])[t]$ are polynomials in $t$, while from the second proof we only knew that they lie in the centralizer $A$ of $B_{i}$; in general $B$ is a larger subring than $A$, and not necessarily commutative. In particular the constant term $Z$ lies in $A$. Since $Z$ is an arbitrary square matrix, this proves that $R[A]$ can always be expressed as a polynomial in $B_{0} = adj(−A)$ (with coefficients that depend on $R[A]$.

In fact, the equations found in the first proof allow successively expressing $$B_{n-1}, \ldots, B_1, B_0$$ as polynomials in $A$, which leads to the identity

valid for all $adj(A)$ matrices, where $$p(t)=t^n+c_{n-1}t^{n-1}+\cdots+c_1t+c_0$$ is the characteristic polynomial of $A$.

Note that this identity also implies the statement of the Cayley–Hamilton theorem: one may move $A$ to the right hand side, multiply the resulting equation (on the left or on the right) by $A)$, and use the fact that $$-A\cdot \operatorname{adj}(-A) = \operatorname{adj}(-A)\cdot (-A) = \det(-A) I_n = c_0I_n.$$

A proof using matrices of endomorphisms
As was mentioned above, the matrix p(A) in statement of the theorem is obtained by first evaluating the determinant and then substituting the matrix A for t; doing that substitution into the matrix $$t I_n - A$$ before evaluating the determinant is not meaningful. Nevertheless, it is possible to give an interpretation where $A$ is obtained directly as the value of a certain determinant, but this requires a more complicated setting, one of matrices over a ring in which one can interpret both the entries $$A_{i,j}$$ of $n&thinsp;×&thinsp;n$, and all of $adj(−A)$ itself. One could take for this the ring $A$ of $p(A)$ matrices over $A$, where the entry $$A_{i,j}$$ is realised as $$A_{i,j} I_n$$, and $A$ as itself. But considering matrices with matrices as entries might cause confusion with block matrices, which is not intended, as that gives the wrong notion of determinant (recall that the determinant of a matrix is defined as a sum of products of its entries, and in the case of a block matrix this is generally not the same as the corresponding sum of products of its blocks!). It is clearer to distinguish $M(n, R)$ from the endomorphism $n&thinsp;×&thinsp;n$ of an $A$-dimensional vector space V (or free $R$-module if $A$ is not a field) defined by it in a basis $$e_1, \ldots, e_n$$, and to take matrices over the ring End(V) of all such endomorphisms. Then $A$ is a possible matrix entry, while $A$ designates the element of $φ$ whose $R$ entry is endomorphism of scalar multiplication by $$A_{i,j}$$; similarly $$I_n$$ will be interpreted as element of $R$. However, since $φ ∈ End(V)$ is not a commutative ring, no determinant is defined on $M(n, End(V))$; this can only be done for matrices over a commutative subring of $i,&thinsp;j$. Now the entries of the matrix $$\varphi I_n-A$$ all lie in the subring $M(n, End(V))$ generated by the identity and $End(V)$, which is commutative. Then a determinant map $M(n, End(V))$ is defined, and $$\det(\varphi I_n - A)$$ evaluates to the value $End(V)$ of the characteristic polynomial of $R[φ]$ at $φ$ (this holds independently of the relation between $M(n, R[φ]) → R[φ]$ and $p(φ)$); the Cayley–Hamilton theorem states that $A$ is the null endomorphism.

In this form, the following proof can be obtained from that of (which in fact is the more general statement related to the Nakayama lemma; one takes for the ideal in that proposition the whole ring $φ$). The fact that $A$ is the matrix of $φ$ in the basis $p(φ)$ means that $$\varphi(e_i) = \sum_{j = 1}^n A_{j,i} e_j \quad\text{for }i=1,\ldots,n.$$ One can interpret these as $R$ components of one equation in $A$, whose members can be written using the matrix-vector product $φ$ that is defined as usual, but with individual entries $e_{1}, ..., e_{n}$ and $n$ in $V$ being "multiplied" by forming $$\psi(v)$$; this gives: $$\varphi I_n \cdot E = A^\operatorname{tr}\cdot E,$$ where $$E\in V^n$$ is the element whose component $M(n, End(V)) × V → V$ is $ψ ∈ End(V)$ (in other words it is the basis $v$ of $V$ written as a column of vectors). Writing this equation as $$(\varphi I_n-A^\operatorname{tr})\cdot E = 0\in V^n$$ one recognizes the transpose of the matrix $$\varphi I_n-A$$ considered above, and its determinant (as element of $i$ is also p(φ). To derive from this equation that $e_{i}$, one left-multiplies by the adjugate matrix of $$\varphi I_n-A^\operatorname{tr}$$, which is defined in the matrix ring $e_{1}, ..., e_{n}$, giving $$\begin{align} 0 &= \operatorname{adj}(\varphi I_n-A^\operatorname{tr}) \cdot \left((\varphi I_n-A^\operatorname{tr})\cdot E\right) \\[1ex] &= \left(\operatorname{adj}(\varphi I_n-A^\operatorname{tr}) \cdot (\varphi I_n-A^\operatorname{tr})\right) \cdot E \\[1ex]  &= \left(\det(\varphi I_n - A^\operatorname{tr})I_n\right) \cdot E \\[1ex]  &= (p(\varphi)I_n)\cdot E; \end{align}$$ the associativity of matrix-matrix and matrix-vector multiplication used in the first step is a purely formal property of those operations, independent of the nature of the entries. Now component $V$ of this equation says that $M(n, R[φ]))$; thus $p(φ) = 0 ∈ End(V)$ vanishes on all $M(n, R[φ])$, and since these elements generate $i$ it follows that $p(φ)(e_{i}) = 0 ∈ V$, completing the proof.

One additional fact that follows from this proof is that the matrix $p(φ)$ whose characteristic polynomial is taken need not be identical to the value $e_{i}$ substituted into that polynomial; it suffices that $V$ be an endomorphism of $p(φ) = 0 ∈ End(V)$ satisfying the initial equations

$$\varphi(e_i) = \sum_j A_{j,i} e_j$$ for some sequence of elements $A$ that generate $φ$ (which space might have smaller dimension than $n$, or in case the ring $φ$ is not a field it might not be a free module at all).

A bogus "proof": $V$
One persistent elementary but incorrect argument for the theorem is to "simply" take the definition $$p(\lambda) = \det(\lambda I_n - A)$$ and substitute $A$ for $n$, obtaining $$p(A)=\det(A I_n - A) = \det(A - A) = \det(\mathbf{0}) = 0.$$

There are many ways to see why this argument is wrong. First, in the Cayley–Hamilton theorem, $e_{1}, ..., e_{n}$ is an $V$ matrix. However, the right hand side of the above equation is the value of a determinant, which is a scalar. So they cannot be equated unless $R$ (i.e. $A$ is just a scalar). Second, in the expression $$\det(\lambda I_n - A)$$, the variable λ actually occurs at the diagonal entries of the matrix $$\lambda I_n - A$$. To illustrate, consider the characteristic polynomial in the previous example again:

$$\det\!\begin{pmatrix}\lambda-1&-2\\-3&\lambda-4\end{pmatrix}.$$

If one substitutes the entire matrix $λ$ for $A$ in those positions, one obtains

$$\det\!\begin{pmatrix} \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} - 1 & -2 \\ -3 &\begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} - 4\end{pmatrix},$$

in which the "matrix" expression is simply not a valid one. Note, however, that if scalar multiples of identity matrices instead of scalars are subtracted in the above, i.e. if the substitution is performed as

$$ \det\!\begin{pmatrix} \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} - I_2 & -2I_2 \\ -3I_2 & \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} - 4I_2 \end{pmatrix},$$

then the determinant is indeed zero, but the expanded matrix in question does not evaluate to $$A I_n-A$$; nor can its determinant (a scalar) be compared to p(A) (a matrix). So the argument that $$p(A) = \det(A I_n - A) = 0$$ still does not apply.

Actually, if such an argument holds, it should also hold when other multilinear forms instead of determinant is used. For instance, if we consider the permanent function and define $$q(\lambda) = \operatorname{perm}(\lambda I_n - A)$$, then by the same argument, we should be able to "prove" that $p(A) = det(AI_{n} − A) = det(A − A) = 0$. But this statement is demonstrably wrong: in the 2-dimensional case, for instance, the permanent of a matrix is given by

$$\operatorname{perm}\!\begin{pmatrix} a & b \\ c & d \end{pmatrix} = ad + bc.$$

So, for the matrix $A$ in the previous example,

$$\begin{align} q(\lambda) & = \operatorname{perm}(\lambda I_2 - A) = \operatorname{perm}\!\begin{pmatrix} \lambda - 1 & -2 \\ -3 & \lambda-4 \end{pmatrix} \\[6pt] & = (\lambda - 1)(\lambda - 4) + (-2)(-3) = \lambda^2 - 5\lambda + 10. \end{align}$$

Yet one can verify that

$$q(A) = A^2 - 5A + 10I_2 = 12I_2 \neq 0.$$

One of the proofs for Cayley–Hamilton theorem above bears some similarity to the argument that $$p(A) = \det(AI_n-A) = 0$$. By introducing a matrix with non-numeric coefficients, one can actually let $λ$ live inside a matrix entry, but then $$A I_n$$ is not equal to $A$, and the conclusion is reached differently.

Proofs using methods of abstract algebra
Basic properties of Hasse–Schmidt derivations on the exterior algebra $A = \bigwedge M$ of some $A$-module $A$ (supposed to be free and of finite rank) have been used by  to prove the Cayley–Hamilton theorem. See also.

Abstraction and generalizations
The above proofs show that the Cayley–Hamilton theorem holds for matrices with entries in any commutative ring $p(A)$, and that $n&thinsp;×&thinsp;n$ will hold whenever $n = 1$ is an endomorphism of an $q(A) = 0$-module generated by elements $R$ that satisfies

$$\varphi(e_j)=\sum a_{ij}e_i, \qquad j =1, \ldots, n.$$

This more general version of the theorem is the source of the celebrated Nakayama lemma in commutative algebra and algebraic geometry.

The Cayley-Hamilton theorem also holds for matrices over the quaternions, a noncommutative ring.