Cayley-Hamilton Calculator

JJ Ben-Joseph headshot JJ Ben-Joseph

What this Cayley–Hamilton calculator does

This tool lets you experiment with the Cayley–Hamilton theorem for a real 2×2 matrix. You enter the four entries of a matrix A and (optionally) an integer power n. The calculator then computes the characteristic polynomial of A, verifies that A satisfies its own polynomial, and helps you see how higher powers of A can be reduced to a simple combination of I and A.

The page is designed for students in linear algebra, people reviewing for exams, and anyone who wants to see the Cayley–Hamilton theorem work out in concrete numerical examples.

Formulas used by the calculator

For a general real 2×2 matrix A=(abcd) the calculator works with two basic quantities:

The characteristic polynomial of A is

p(\u03bb) = \u03bb2 - t\u03bb + d0

The Cayley–Hamilton theorem states that if you substitute the matrix A into its characteristic polynomial, you get the zero matrix:

p(A)=A2tA+d0I=0, where I is the 2×2 identity matrix and 0 denotes the 2×2 zero matrix.

For powers of A, the key idea is that any polynomial in A can be simplified using this relation. In particular, for a 2×2 matrix you can always reduce higher powers to a linear combination of I and A. For example, starting from

A2=tA-d0I

you can multiply both sides by A to find

A 3 = t A 2 - d 0 A = t ( t A - d 0 I ) - d 0 A = ( t 2 - d 0 ) A - t d 0 I .

The calculator uses these same underlying formulas internally when it checks the theorem for the matrix you enter.

How to use the Cayley–Hamilton calculator

To run a basic verification:

  1. Enter the matrix entries. Fill in the four number inputs representing the matrix A=abcd. The input boxes correspond to a11=a, a12=b, a21=c, and a22=d.
  2. Choose a power n (optional). The field labeled “Power n for An” lets you pick a positive integer power to explore. Even if you do not focus on An, the theorem verification will still work.
  3. Run the verification. Press the button to verify the Cayley–Hamilton theorem. The script computes the trace t, the determinant d0, the characteristic polynomial, and the matrix expression A2tA+d0I.
  4. Inspect the result matrix. Ideally, all four entries of A2tA+d0I are numerically very close to zero. Because of rounding, you may see tiny nonzero values (for example, on the order of 10−7 or 10−10), but they should be small.

If you supplied a power n, the tool may also compute An and, when possible, express it in terms of I and A using the Cayley–Hamilton relation.

Interpreting the calculator output

When you run the calculator, you will typically see at least two pieces of output:

Conceptually, if the Cayley–Hamilton theorem holds and there is no rounding error, that verification matrix should be exactly the zero matrix:

A2tA+d0I=0000.

Numerically, computers work with floating-point arithmetic, so you may see entries like 1.0×10−9 instead of 0. These are effectively zero for practical purposes and simply reflect limited precision.

If you also compute An, you can compare the directly computed power with the value obtained by repeatedly applying the relation A2=tA-d0I. Both approaches should agree up to rounding error, illustrating how Cayley–Hamilton turns high powers of a matrix into a simpler combination of I and A.

Worked example: a specific rotation matrix

Consider a 2D rotation by 60°. The associated rotation matrix is

A=cos60°sin60°sin60°cos60°=0.50.86602540.86602540.5.

To test this matrix in the calculator:

  1. Set a11=0.5.
  2. Set a12=-0.8660254.
  3. Set a21=0.8660254.
  4. Set a22=0.5.
  5. Leave the power n at 2 (or choose another small integer).
  6. Click the button to verify the theorem.

The calculator will compute the trace and determinant:

So the characteristic polynomial is approximately λ2λ+1. By Cayley–Hamilton, this implies

A2A+I=0

After running the computation, the displayed entries of A2A+I should all be very close to zero. If you ask the tool to compute A3, you can then express it using the polynomial relation, confirming that repeated rotations still follow the same algebraic rules.

Comparison with other 2×2 matrix types

Different kinds of 2×2 matrices give different traces and determinants, but they all satisfy the same general Cayley–Hamilton pattern. The table below summarizes a few typical cases you can try in the calculator.

Matrix type Example A Trace t Determinant d0 Characteristic polynomial
Diagonal (2003) 2+3=5 23=6 λ^2-5λ+6
Scalar 4004 4+4=8 44=16 λ28λ+16=(λ4)2
Rotation (orthogonal) (cosθ-sinθsinθcosθ) 2cosθ 1 λ22cosθλ+1
Repeated eigenvalue, not diagonal 1101 1+1=2 1101=1 λ22λ+1=(λ1)2

You can enter each of these matrices into the calculator and verify that A2tA+d0I is numerically the zero matrix in every case, even when the matrix is not diagonalizable (as in the last example).

Limitations, assumptions, and numerical notes

This demonstrator is intentionally simple and has a few built-in limitations you should keep in mind while interpreting results:

Within these constraints, the calculator should give a faithful numerical illustration of the Cayley–Hamilton theorem and how it controls powers and polynomials of a 2×2 matrix.

Enter matrix entries.

Embed this calculator

Copy and paste the HTML below to add the Cayley-Hamilton Calculator – Verify the Theorem for 2×2 Matrices to your website.