Characteristic Polynomial Calculator
The characteristic polynomial of a square matrix A is p(λ) = det(λI - A), a degree n polynomial whose roots are the eigenvalues. For the 2x2 matrix with rows 2,1 and 1,2 the calculator returns λ² - 4λ + 3, so the eigenvalues are 1 and 3, the trace is 4 and the determinant is 3.
Enter any numbers, negative or decimal included. Every calculation runs in your browser and nothing is uploaded.
| Characteristic polynomial | λ² - 4λ + 3 |
| Eigenvalues (roots) | 1, 3 |
| Matrix size | 2 x 2 |
| Trace (sum of diagonal) | 4 |
| Determinant | 3 |
| Check: p(0) versus determinant | p(0) = 3, matches |
| Check: sum of roots versus trace | 4 = 4, matches |
| Check: product of roots versus determinant | 3 = 3, matches |
| Check: Cayley-Hamilton residual | max |p(A)| = 0, matches |
| Method | 2 x 2 closed form, then Faddeev-LeVerrier |
All computations operate on client-side mathematics. No data is transmitted or stored.
Build the characteristic polynomial of a 2x2, 3x3 or 4x4 matrix, list its eigenvalues, and see the trace, determinant and Cayley-Hamilton checks confirm the result.
Key takeaways
- The characteristic polynomial is p(λ) = det(λI - A), always monic with degree equal to the matrix size.
- The coefficient of λⁿ⁻¹ is minus the trace, and the constant term is (-1)ⁿ times the determinant, which gives two free checks on every answer.
- The eigenvalues are the roots of the polynomial. They sum to the trace and multiply to the determinant.
- Faddeev-LeVerrier produces the coefficients from matrix products alone, so it needs no symbolic algebra and works at any size.
- Cayley-Hamilton says p(A) is the zero matrix, which the calculator verifies numerically for every matrix you enter.
On this page
- What a Characteristic Polynomial Is
- Reading the Coefficients: Trace, Determinant and the Constant Term
- How the Calculator Works: Faddeev-LeVerrier Step by Step
- Worked Examples from 2x2 up to 4x4
- The 3x3 and 4x4 Cases in Detail
- Complex Eigenvalues and What They Mean
- Four Checks That Catch Mistakes
- Common Traps: Sign Conventions, Shape and Repeated Roots
What a Characteristic Polynomial Is
A characteristic polynomial turns a square matrix into a single polynomial. Take an n by n matrix A, subtract λ from every diagonal entry, and take the determinant: p(λ) = det(λI - A). The result is a polynomial of degree n, and its roots are the eigenvalues of A. That is the whole idea, and it is the reason this page exists.
The LibreTexts linear algebra text states the definition the same way and proves that a number is an eigenvalue exactly when it makes the determinant zero. MIT OpenCourseWare covers the same ground in 18.06 Linear Algebra, where the determinant and eigenvalue lectures sit next to each other for a reason: one produces the other.
Why bother with the polynomial instead of hunting eigenvalues directly? Because a polynomial is a familiar object. Once you have λ³ - 7λ² + 14λ - 8 in hand, you can factor it, graph it, apply the rational root test, or hand it to any root finder. The matrix disappears and only ordinary algebra remains.
This calculator builds that polynomial for 2 by 2, 3 by 3, and 4 by 4 matrices, lists the eigenvalues it finds, and then runs three independent checks so you can see the answer is consistent rather than trusting it.
Reading the Coefficients: Trace, Determinant and the Constant Term
The coefficients of the characteristic polynomial are not random numbers. Each one is a summary of the matrix, and the pattern is worth memorizing because it gives you a free error check on any result.
Write the polynomial in the standard monic form p(λ) = λⁿ + c₁λⁿ⁻¹ + c₂λⁿ⁻² + ... + cₙ. Then c₁ = -(trace of A), where the trace is the sum of the diagonal entries. The constant term is cₙ = (-1)ⁿ times the determinant. In between the coefficients are sums of principal minors, which is a tidy fact but rarely needed by hand.
| Size | Polynomial shape | Trace link | Determinant link |
|---|---|---|---|
| 2 x 2 | λ² + c₁λ + c₂ | c₁ = -trace | c₂ = det |
| 3 x 3 | λ³ + c₁λ² + c₂λ + c₃ | c₁ = -trace | c₃ = -det |
| 4 x 4 | λ⁴ + c₁λ³ + c₂λ² + c₃λ + c₄ | c₁ = -trace | c₄ = det |
Two rules fall out of this table. The sum of the eigenvalues equals the trace. The product of the eigenvalues equals the determinant. Both hold for every square matrix, including matrices with repeated roots and matrices with complex roots.
That gives a quick sanity test anyone can run without a computer. If the polynomial constant term and the determinant disagree in sign for a 2 by 2 matrix, one of them is wrong. If the eigenvalues add up to something other than the diagonal sum, the roots are wrong, not the trace.
How the Calculator Works: Faddeev-LeVerrier Step by Step
The calculator uses the Faddeev-LeVerrier recursion. It builds the coefficients one at a time from matrix products, so no symbolic algebra is needed and the method works the same at every size.
Start with M₀ as the zero matrix and c₀ = 1. For k from 1 to n, set Mₖ = A·Mₖ₋₁ + cₖ₋₁·I, then set cₖ = -trace(A·Mₖ) / k. After n steps the numbers c₁ through cₙ are the coefficients you want. The final matrix product A·Mₙ + cₙ·I is the zero matrix, which is Cayley-Hamilton showing up in the middle of the computation.
| Step k | Matrix built | Coefficient produced | Meaning |
|---|---|---|---|
| 1 | M₁ = I | c₁ = -trace(A) | negative trace |
| 2 | M₂ = A + c₁I | c₂ = -trace(A·M₂) / 2 | sum of principal 2 by 2 minors |
| 3 | M₃ = A·M₂ + c₂I | c₃ = -trace(A·M₃) / 3 | negative sum of principal 3 by 3 minors |
| n | Mₙ = A·Mₙ₋₁ + cₙ₋₁I | cₙ = -trace(A·Mₙ) / n | (-1)ⁿ times the determinant |
For a 2 by 2 matrix the recursion collapses into the closed form everyone learns: p(λ) = λ² - (trace)λ + (determinant). With rows 2 and 1, then 1 and 2, the trace is 4 and the determinant is 3, so p(λ) = λ² - 4λ + 3 and the eigenvalues are 1 and 3.
For 3 by 3 and 4 by 4 the calculator still runs the recursion exactly, then finds roots numerically with the Durand-Kerner method. That method works on complex numbers directly, so a matrix with no real eigenvalues still gets a complete, correctly paired answer instead of an error message.
Worked Examples from 2x2 up to 4x4
A first example, done by hand. Take A with first row 1 and 2, second row 3 and 4. The trace is 1 + 4 = 5. The determinant is 1 x 4 - 2 x 3 = -2. So the characteristic polynomial is λ² - 5λ - 2.
The quadratic formula gives λ = (5 ± √33) / 2, which is 5.372281 and -0.372281. Both are real, one positive and one negative, so this matrix stretches along one direction and flips along another. The calculator reports exactly those two roots and shows the sum 5, matching the trace, and the product -2, matching the determinant.
| Matrix | Characteristic polynomial | Eigenvalues | Trace | Determinant |
|---|---|---|---|---|
| 2, 1 then 1, 2 | λ² - 4λ + 3 | 1, 3 | 4 | 3 |
| 1, 2 then 3, 4 | λ² - 5λ - 2 | -0.372281, 5.372281 | 5 | -2 |
| 0, -1 then 1, 0 | λ² + 1 | 0 ± 1i | 0 | 1 |
| 3 by 3, rows 2 1 0, 1 3 1, 0 1 2 | λ³ - 7λ² + 14λ - 8 | 1, 2, 4 | 7 | 8 |
| 4 by 4 diagonal 1, 2, 3, 4 | λ⁴ - 10λ³ + 35λ² - 50λ + 24 | 1, 2, 3, 4 | 10 | 24 |
The symmetric 2 by 2 case on the first row is the friendliest one to check. Its rows are 2, 1 and 1, 2, so the trace is 4 and the determinant is 4 - 1 = 3. The polynomial λ² - 4λ + 3 factors as (λ - 1)(λ - 3), and the roots 1 and 3 are both real, which always happens for a symmetric matrix.
Notice the constant term of the 3 by 3 example is -8 while the determinant is 8. That is not a bug. For odd sizes the constant term carries a minus sign, which the next section covers.
The 3x3 and 4x4 Cases in Detail
The 3 by 3 example deserves its own walkthrough because the middle coefficient is where hand work usually goes wrong. Take rows 2, 1, 0 and 1, 3, 1 and 0, 1, 2. The trace is 2 + 3 + 2 = 7, so c₁ = -7.
The determinant is 8, so c₃ = -8 for a 3 by 3 matrix. The middle coefficient c₂ is the sum of the three principal 2 by 2 minors: the minor on rows and columns 1 and 2 is 2 x 3 - 1 x 1 = 5, the minor on rows and columns 2 and 3 is 3 x 2 - 1 x 1 = 5, and the minor on rows and columns 1 and 3 is 2 x 2 - 0 x 0 = 4. The sum is 14, so p(λ) = λ³ - 7λ² + 14λ - 8.
That polynomial factors cleanly as (λ - 1)(λ - 2)(λ - 4). The eigenvalues 1, 2, and 4 add to 7, which matches the trace, and multiply to 8, which matches the determinant. The calculator returns the same three roots and marks all three checks as matching.
The 4 by 4 diagonal example is easier still. A diagonal matrix has its eigenvalues sitting on the diagonal, so the roots are 1, 2, 3, and 4 before any work is done. The polynomial is (λ - 1)(λ - 2)(λ - 3)(λ - 4), which multiplies out to λ⁴ - 10λ³ + 35λ² - 50λ + 24. The constant term 24 equals the determinant, which is the product 1 x 2 x 3 x 4.
A non-diagonal 4 by 4 is available too. Try a symmetric tridiagonal matrix with rows 4 1 0 0, 1 3 1 0, 0 1 2 1, 0 0 1 1. The calculator returns λ⁴ - 10λ³ + 32λ² - 35λ + 7 with roots 0.254719, 1.822717, 3.177283, and 4.745281, and those four roots add to 10, the trace.
Complex Eigenvalues and What They Mean
Real roots are only half the story. A rotation matrix has no real eigenvalue at all, and that is a meaningful fact rather than a failure of the method. Take rows 0, -1 and 1, 0, which rotates every vector by 90 degrees counterclockwise.
Its trace is 0 and its determinant is 1, so p(λ) = λ² + 1. That polynomial has no real root, and the roots are 0 + 1i and 0 - 1i, which the calculator shows as 0 ± 1i. A rotation does not stretch any real arrow, so no real eigenvalue should exist. The complex pair is the algebra telling you the truth about the geometry.
A 4 by 4 built from two rotation blocks gives two conjugate pairs. Take rows 0 -1 0 0, 1 0 0 0, 0 0 0 -2, 0 0 2 0. The trace is 0, the determinant is 4, and the polynomial is λ⁴ + 5λ² + 4, with roots 0 ± 1i and 0 ± 2i. Four complex roots, no real ones, and the matrix is a pair of independent rotations in two planes.
| Input | Polynomial | Roots | What it means |
|---|---|---|---|
| 0, -1 then 1, 0 | λ² + 1 | 0 ± 1i | quarter turn rotation, no real stretch |
| 3 by 3 with a rotation block plus 2 | λ³ - 2λ² + λ - 2 | 2, 0 ± 1i | one real stretch, one rotation plane |
| two rotation blocks, radius 1 and 2 | λ⁴ + 5λ² + 4 | 0 ± 1i, 0 ± 2i | two independent rotation planes |
Complex roots always arrive in conjugate pairs when the matrix has real entries. That is why the output groups them as a ± bi instead of listing them separately. The pair together contributes a squared magnitude to the determinant and a doubled real part to the trace, so the checks still balance.
Geometrically, a complex pair means the map rotates and scales within a plane. The eigenvalue magnitude, meaning the distance from zero to the complex number, is the scale factor for that plane. For 0 ± 2i the magnitude is 2, so lengths in that plane double on each application.
Four Checks That Catch Mistakes
Three checks run every time the calculator updates, and each one tests a different part of the result. Watching them turn from matches to does not match is the fastest way to spot a typo in a matrix entry.
| Check | What it compares | Why it works |
|---|---|---|
| Constant term | p(0) against (-1)ⁿ det(A) | p(0) = det(-A), and a minus sign factors out once per row |
| Sum of roots | Σλ against trace(A) | the λⁿ⁻¹ coefficient is minus the trace, by Vieta |
| Product of roots | Πλ against det(A) | the constant term is (-1)ⁿ times the product |
| Cayley-Hamilton | largest entry of p(A) against 0 | every matrix satisfies its own characteristic polynomial |
Cayley-Hamilton is the boldest of the four. It says that substituting the matrix itself into its own characteristic polynomial gives the zero matrix. So for the 2 by 2 with rows 2, 1 and 1, 2, whose polynomial is λ² - 4λ + 3, it claims that A² - 4A + 3I equals the zero matrix.
Check it by hand. A² is rows 5, 4 and 4, 5. Four times A is rows 8, 4 and 4, 8. Three times I is rows 3, 0 and 0, 3. Then 5 - 8 + 3 = 0, 4 - 4 + 0 = 0, and the same on the other diagonal. Every entry lands on zero.
The calculator reports the largest absolute entry of p(A) as a number like 0.00e+0. Tiny values near 10⁻¹⁶ can appear from floating point rounding, which is why the check uses a tolerance instead of demanding an exact zero.
A failed check is useful information, not a reason to distrust the tool. It means the inputs contain something the arithmetic cannot reconcile, such as a matrix with an entry so large that the determinant overflows, or a size setting that does not match the numbers you typed.
Common Traps: Sign Conventions, Shape and Repeated Roots
Four traps catch most people who compute characteristic polynomials by hand or by code.
The first is the sign convention. Some textbooks define the characteristic polynomial as det(A - λI) instead of det(λI - A). Both definitions have the same roots, so the eigenvalues never change, but for odd n the polynomial you get is the negative of the other one. MathWorld notes both forms and uses det(λI - A) for the monic version. This calculator uses the monic form, so the leading coefficient is always 1 and the constant term is (-1)ⁿ det(A).
| Size | det(λI - A) | det(A - λI) | Same roots? |
|---|---|---|---|
| 2 x 2 | λ² - 4λ + 3 | λ² - 4λ + 3 | yes, identical |
| 3 x 3 | λ³ - 7λ² + 14λ - 8 | -λ³ + 7λ² - 14λ + 8 | yes, signs flipped |
| 4 x 4 | λ⁴ - 10λ³ + 35λ² - 50λ + 24 | same as left | yes, identical |
The second trap is trying this on a non-square matrix. The determinant of a 2 by 3 array does not exist, so the characteristic polynomial does not exist either. The calculator only accepts square sizes for that reason.
The third is assuming similar matrices must look alike. They need not. A matrix and its diagonal form can look completely different and still share one characteristic polynomial, because similarity preserves determinant and trace at every size. That is the basis for diagonalization: if you can find the eigenvalues, you can often rebuild the same map in a simpler basis.
The fourth is forgetting repeated roots. A matrix can have an eigenvalue of multiplicity 2 or 3, and the polynomial shows that as a squared or cubed factor. The calculator lists each root once per multiplicity, so a double root appears twice in the eigenvalue row, which is correct and not a duplicate bug.
Frequently asked questions
What is the characteristic polynomial of a 2x2 matrix?
For a 2x2 matrix the characteristic polynomial is λ² - (trace)λ + (determinant). With rows 2, 1 and 1, 2 the trace is 4 and the determinant is 3, so p(λ) = λ² - 4λ + 3 and the eigenvalues are 1 and 3.
How do I find the characteristic polynomial of a 3x3 matrix?
Use λ³ - (trace)λ² + (sum of principal 2x2 minors)λ - (determinant). For rows 2 1 0, 1 3 1, 0 1 2 the trace is 7, the minor sum is 14 and the determinant is 8, giving λ³ - 7λ² + 14λ - 8.
Why is my polynomial the negative of the one on this page?
You likely used det(A - λI) instead of det(λI - A). Both have the same roots, so the eigenvalues match. For odd sizes the two polynomials differ by an overall minus sign. This calculator uses the monic form det(λI - A) with a leading coefficient of 1.
How many eigenvalues does a 4x4 matrix have?
Four, counted with multiplicity, because the characteristic polynomial has degree 4. They can all be real, all complex, or a mix. The diagonal example with entries 1, 2, 3, 4 returns λ⁴ - 10λ³ + 35λ² - 50λ + 24 with roots 1, 2, 3 and 4.
What does the constant term of the characteristic polynomial tell me?
The constant term equals (-1)ⁿ times the determinant, where n is the matrix size. For a 3x3 with determinant 8 the constant term is -8. Setting λ to 0 in det(λI - A) leaves det(-A), and each row contributes one minus sign.
Can a matrix have no real eigenvalues?
Yes. The rotation matrix with rows 0, -1 and 1, 0 has p(λ) = λ² + 1, whose roots are 0 ± 1i. A rotation never stretches a real vector, so no real eigenvalue exists. The calculator shows the complex pair as 0 ± 1i.
What is the Cayley-Hamilton theorem in plain terms?
Every square matrix satisfies its own characteristic polynomial. If p(λ) = λ² - 4λ + 3, then A² - 4A + 3I equals the zero matrix. The calculator substitutes your matrix and reports the largest entry left over, which should be 0.
Do similar matrices have the same characteristic polynomial?
Yes. Similar matrices share the same determinant, trace and every coefficient in between, so their characteristic polynomials are identical and so are their eigenvalues. Their eigenvectors usually differ, because they live in a different basis.
Why does the calculator show a tiny number like 1e-16 instead of zero?
Floating point arithmetic carries about 16 significant digits, so a result that should be exactly zero can land near 10⁻¹⁶. The Cayley-Hamilton check uses a tolerance and still reports a match when the largest entry sits below that threshold.
Can I enter decimals and negative numbers?
Yes. Every cell accepts decimals, negatives and zero, and blank cells count as 0 so the calculator never breaks. For example rows -2, 0.5 and 0.5, -3 give p(λ) = λ² + 5λ + 5.75, trace -5 and determinant 5.75.
What is the trace of a matrix and how is it related to eigenvalues?
The trace is the sum of the diagonal entries, and it equals the sum of the eigenvalues. A 3x3 with trace 7 has eigenvalues that add to 7, as in 1 + 2 + 4. The calculator compares both numbers on every run.
Does the order of the coefficients matter?
Yes. The standard monic order runs from the highest power down: λⁿ, then λⁿ⁻¹, and so on to the constant. Reading 1, -7, 14, -8 as a 3x3 result means λ³ - 7λ² + 14λ - 8, not the reverse.
How does the Faddeev-LeVerrier method work?
It builds a matrix sequence where each step multiplies by A and adds a multiple of the identity, then takes a trace to produce one coefficient. After n steps you have all n coefficients, and the last matrix product is the zero matrix by Cayley-Hamilton.
Can I use this for a 5x5 matrix?
This page handles 2x2, 3x3 and 4x4, which cover almost all homework and exam problems. A 5x5 needs the same recursion, but root finding gets slower and hand checking gets hard, so the page keeps to the sizes people meet in practice.
Spotted a wrong number or a broken result?
More Math tools
Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.