Cayley-Hamilton Calculator
Introduction: 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 and (optionally) an integer power . The calculator then computes the characteristic polynomial of , verifies that satisfies its own polynomial, and helps you see how higher powers of can be reduced to a simple combination of and .
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 the calculator works with two basic quantities:
- The trace of : .
- The determinant of : , which we denote by below to avoid confusion with the bottom-right entry of the matrix.
The characteristic polynomial of is
The Cayley–Hamilton theorem states that if you substitute the matrix into its characteristic polynomial, you get the zero matrix:
where is the 2×2 identity matrix and denotes the 2×2 zero matrix.
For powers of , the key idea is that any polynomial in can be simplified using this relation. In particular, for a 2×2 matrix you can always reduce higher powers to a linear combination of and . For example, starting from
you can multiply both sides by to find
Formula: 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:
- Enter the matrix entries. Fill in the four number inputs representing the matrix . The input boxes correspond to , , , and .
- Choose a power (optional). The field labeled “Power for ” lets you pick a positive integer power to explore. Even if you do not focus on , the theorem verification will still work.
- Run the verification. Press the button to verify the Cayley–Hamilton theorem. The script computes the trace , the determinant , the characteristic polynomial, and the matrix expression .
- Inspect the result matrix. Ideally, all four entries of 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 , the tool may also compute and, when possible, express it in terms of and using the Cayley–Hamilton relation.
Interpreting the calculator output
When you run the calculator, you will typically see at least two pieces of output:
- The characteristic polynomial in the form , where and are computed from your matrix.
- The verification matrix .
Conceptually, if the Cayley–Hamilton theorem holds and there is no rounding error, that verification matrix should be exactly the zero matrix:
Formula: A^2 − t A + d_0 I = 0 0 0 0.
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 , you can compare the directly computed power with the value obtained by repeatedly applying the relation . Both approaches should agree up to rounding error, illustrating how Cayley–Hamilton turns high powers of a matrix into a simpler combination of and .
Worked example: a specific rotation matrix
Consider a 2D rotation by 60°. The associated rotation matrix is
Formula: A = cos 60 ° − sin 60 ° sin 60 ° cos 60 ° = 0.5 − 0.8660254 0.8660254 0.5.
To test this matrix in the calculator:
- Set .
- Set .
- Set .
- Set .
- Leave the power at 2 (or choose another small integer).
- Click the button to verify the theorem.
The calculator will compute the trace and determinant:
- .
- .
So the characteristic polynomial is approximately . By Cayley–Hamilton, this implies
Formula: A^2 − A + I = 0
After running the computation, the displayed entries of should all be very close to zero. If you ask the tool to compute , 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 | Trace | Determinant | Characteristic polynomial |
|---|---|---|---|---|
| Diagonal | ||||
| Scalar | ||||
| Rotation (orthogonal) | ||||
| Repeated eigenvalue, not diagonal |
You can enter each of these matrices into the calculator and verify that 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:
- Matrix size. The tool only handles 2×2 matrices. The Cayley–Hamilton theorem holds for all square matrices of any size, but the polynomial and algebra become more complicated for 3×3 or larger matrices.
- Real entries only. Inputs are treated as real numbers. Matrices with complex entries are not directly supported, although you can still explore cases whose eigenvalues are complex (like rotation matrices) because the matrix itself has real entries.
- Floating‑point rounding. The computations use standard floating-point arithmetic. You should expect small residuals instead of exact zeros, especially if matrix entries are large in magnitude or very small.
- Choice of power . The power field is intended for positive integers within a practical range. Very large powers can amplify rounding errors and may be slow or unstable numerically.
- Ill-conditioned matrices. If the matrix is nearly singular (its determinant is very close to zero) or has widely separated scales in its entries, small numerical errors in , , or can lead to more noticeable nonzero entries in . This does not contradict the theorem; it simply reflects sensitivity to rounding.
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.
Arcade Mini-Game: Cayley-Hamilton Calculator Calibration Run
Use this quick arcade run to practice separating useful scenario inputs from common planning mistakes before you rely on the calculator output.
Start the game, then use your pointer or arrow keys to catch useful inputs and avoid bad assumptions.
