---
title: "CharacteristicPolynomial"
language: "en"
type: "Symbol"
summary: "CharacteristicPolynomial[m, x] gives the characteristic polynomial for the matrix m. CharacteristicPolynomial[{m, a}, x] gives the generalized characteristic polynomial with respect to a."
keywords: 
- Cayley–Hamilton
- secular function
- secular equation
- characteristic roots
- matrix polynomial
- eigenvalues
- determinant of characteristic matrix
- charpoly
- poly
canonical_url: "https://reference.wolfram.com/language/ref/CharacteristicPolynomial.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Matrix Operations"
    link: "https://reference.wolfram.com/language/guide/MatrixOperations.en.md"
  - 
    title: "Finite Fields"
    link: "https://reference.wolfram.com/language/guide/FiniteFields.en.md"
related_functions: 
  - 
    title: "Eigenvalues"
    link: "https://reference.wolfram.com/language/ref/Eigenvalues.en.md"
  - 
    title: "Det"
    link: "https://reference.wolfram.com/language/ref/Det.en.md"
  - 
    title: "Eigensystem"
    link: "https://reference.wolfram.com/language/ref/Eigensystem.en.md"
related_tutorials: 
  - 
    title: "Basic Matrix Operations"
    link: "https://reference.wolfram.com/language/tutorial/LinearAlgebra.en.md#25697"
  - 
    title: "Eigenvalues and Eigenvectors"
    link: "https://reference.wolfram.com/language/tutorial/LinearAlgebra.en.md#9501"
---
# CharacteristicPolynomial

CharacteristicPolynomial[m, x] gives the characteristic polynomial for the matrix m. 

CharacteristicPolynomial[{m, a}, x] gives the generalized characteristic polynomial with respect to a.

## Details

* ``m`` must be a square matrix.

* It can contain numeric or symbolic entries.

* ``CharacteristicPolynomial[m, x]`` is essentially equivalent to ``Det[m - id x]`` where ``id`` is the identity matrix of appropriate size. »

* ``CharacteristicPolynomial[{m, a}, x]`` is essentially ``Det[m - a x]``. »

---

## Examples (36)

### Basic Examples (3)

Find the characteristic polynomial of a matrix with integer entries:

```wl
In[1]:= CharacteristicPolynomial[{{1, 2}, {3, 4}}, x]

Out[1]= -2 - 5 x + x^2
```

Visualize the polynomial:

```wl
In[2]:= Plot[%, {x, -5, 10}]

Out[2]= [image]
```

---

Find the characteristic polynomial in $x$ of the symbolic matrix $m$ :

```wl
In[1]:=
m = (⁠|   |   |
| - | - |
| a | b |
| c | d |⁠);

In[2]:= CharacteristicPolynomial[m, x]

Out[2]= -b c + a d - a x - d x + x^2
```

Compare with a direct computation:

```wl
In[3]:= Det[m - x IdentityMatrix[2]]

Out[3]= -b c + a d - a x - d x + x^2
```

---

Compute the characteristic polynomials of the identity matrix and zero matrix:

```wl
In[1]:= CharacteristicPolynomial[IdentityMatrix[3], λ]

Out[1]= 1 - 3 λ + 3 λ^2 - λ^3

In[2]:= CharacteristicPolynomial[ConstantArray[0, {10, 10}], λ]

Out[2]= λ^10
```

### Scope (17)

#### Basic Uses (7)

Find the characteristic polynomial of a machine-precision matrix:

```wl
In[1]:= CharacteristicPolynomial[{{1.1, 2.2, 3.25}, {0.76, 4.6, 5}, {0.1, 0.1, 6.1}}, x]

Out[1]= 19.9688  - 37.333 x + 11.8 x^2 - x^3
```

---

Arbitrary-precision matrix:

```wl
In[1]:= CharacteristicPolynomial[Table[N[1 / (i + j + 1), 20], {i, 3}, {j, 3}], x]

Out[1]= 2.64550264550264550264550264550265`19.522878745280337*^-6 - 0.012579365079365079365 x + 0.67619047619047619048 x^2 - x^3
```

---

Characteristic polynomial of a complex matrix:

```wl
In[1]:= CharacteristicPolynomial[{{1.2 + I, 3 - 2 I, 3 π}, {-0.2, 5I, 2}, {1, 2.3, E}}, x]

Out[1]= (-15.8158 - 40.5015 I) + (15.1628  - 21.9097 I) x + (3.91828  + 6. I) x^2 - x^3
```

---

Characteristic polynomial of an exact matrix:

```wl
In[1]:= CharacteristicPolynomial[{{(1/3), (1/2), (3/5)}, {(1/2), (4/5), 1}, {(3/5), 1, (9/7)}}, x]

Out[1]= (1/10500) - (239 x/2100) + (254 x^2/105) - x^3
```

Visualize the result:

```wl
In[2]:= Plot[%, {x, -1.5, 2.5}]

Out[2]= [image]
```

---

The characteristic polynomials of large numerical matrices are computed efficiently:

```wl
In[1]:= m = RandomReal[{1, 9}, {100, 100}];

In[2]:= CharacteristicPolynomial[m, x];//Timing

Out[2]= {0.020851, Null}
```

---

Characteristic polynomial of a matrix with finite field elements:

```wl
In[1]:=
ℱ = FiniteField[43, 2];
CharacteristicPolynomial[{{ℱ[12], ℱ[23], ℱ[34]}, {ℱ[45], ℱ[56], ℱ[67]}, {ℱ[78], ℱ[89], ℱ[90]}}, x]

Out[1]= [image]
```

---

Characteristic polynomial of a matrix containing ``CenteredInterval`` objects:

```wl
In[1]:= (m = Map[CenteredInterval, RandomReal[{-10, 10}, {3, 3}, WorkingPrecision -> 10], {2}])//MatrixForm

Out[1]//MatrixForm=
(⁠|                                                             |                                                             |                                                            |
| --------------------------------------------------------- ... nteredInterval[{{-1380172515, -31, 592779582, -63}, 44}] |
| CenteredInterval[{{23632689015, -32, 634385166, -60}, 44}]  | CenteredInterval[{{18633889075, -31, 1000399303, -60}, 44}] | CenteredInterval[{{14823894835, -32, 795851794, -61}, 44}] |⁠)

In[2]:= p = CharacteristicPolynomial[m, x]

Out[2]= CenteredInterval[{{2300675247515, -37, 760805543, -52}, 44}] + CenteredInterval[{{13429493780211, -40, 587129359, -55}, 44}] x + CenteredInterval[{{-3623460215, -30, 592458937, -59}, 44}] x^2 + CenteredInterval[{{-1, 0, 0, -30}, 44}] x^3
```

Find a random representative ``mrep`` of ``m`` :

```wl
In[3]:=
ranrep[e_CenteredInterval] := e["Center"] + RandomInteger[{-1000, 1000}] / 1000 e["Radius"]
(mrep = Map[ranrep, m, {2}])//MatrixForm

Out[3]//MatrixForm=
(⁠|                                                   |                                                  |                                                |
| ------------------------------------------------- | -------------------------------------- ... 6196815107441127/922337203685477580800)  | -(296389790752083792177/461168601842738790400) |
| (317192582610165443919/57646075230342348800)      | (10003993021260870377077/1152921504606846976000) | (124351842812396123837/36028797018963968000)   |⁠)
```

Verify that the coefficients of ``p`` contain the coefficients of the characteristic polynomial of ``mrep`` :

```wl
In[4]:= MapThread[IntervalMemberQ, {CoefficientList[p, x], CoefficientList[CharacteristicPolynomial[mrep, x], x]}]

Out[4]= {True, True, True, True}
```

#### Generalized Eigenvalues (4)

The generalized characteristic polynomial of two matrices:

```wl
In[1]:= m1 = {{1, 2}, {5, 4}};m2 = {{4, 3}, {6, 4}};

In[2]:= CharacteristicPolynomial[{m1, m2}, x]

Out[2]= -6 + 7 x - 2 x^2
```

This is equivalent to $\left| m_1-x m_2\right|$ :

```wl
In[3]:= Det[m1 - x m2]

Out[3]= -6 + 7 x - 2 x^2
```

---

A generalized characteristic polynomial of machine-precision matrices:

```wl
In[1]:= a = {{1., 1.5, 2.}, {3.1, 2., 2.9}, {3., 2., 1.}};

In[2]:= b = {{1.3, .5, 1.1}, {0., 1.5, 2.3}, {1., 0., 1.}};

In[3]:= CharacteristicPolynomial[{a, b}, x]

Out[3]= 5.  + 5.97 x - 3.28 x^2 - 1.45 x^3
```

---

Find a generalized exact characteristic polynomial:

```wl
In[1]:= a = {{1, 1, 1}, {1, 0, 1}, {0, 0, 1}};

In[2]:= b = {{0, 1, 1}, {0, 1, 1}, {1, 0, 0}};

In[3]:= CharacteristicPolynomial[{a, b}, x]

Out[3]= -1 - x + x^2
```

The absence of an $x^3$ term indicates an infinite generalized eigenvalue:

```wl
In[4]:= Eigenvalues[{a, b}]

Out[4]= {∞, (1/2) (1 + Sqrt[5]), (1/2) (1 - Sqrt[5])}
```

Compute the result at finite precision:

```wl
In[5]:= CharacteristicPolynomial[N[{a, b}, 20], y]

Out[5]= -1.0000000000000000000 - 1.0000000000000000000 y + 1.0000000000000000000 y^2 + 0``19.397940008672045 y^3
```

---

Find the generalized characteristic polynomial of symbolic matrices:

```wl
In[1]:=
a = {{x, 1 + x}, {1 - x, x}};b = {{1, 1}, {1, 2x}};
CharacteristicPolynomial[{a, b}, y]

Out[1]= -1 + 2 x^2 + 2 y - x y - 2 x^2 y - y^2 + 2 x y^2
```

#### Special Matrices (6)

Characteristic polynomials of sparse matrices:

```wl
In[1]:= SparseArray[{{1, 3} -> 2, {2, 2} -> 3, {3, 1} -> 1, {4, 2} -> 5}, {4, 4}]

Out[1]= SparseArray[Automatic, {4, 4}, 0, {1, {{0, 1, 2, 3, 4}, {{3}, {2}, {1}, {2}}}, {2, 3, 1, 5}}]

In[2]:= CharacteristicPolynomial[%, x]

Out[2]= 6 x - 2 x^2 - 3 x^3 + x^4

In[3]:= SparseArray[{{x_, y_} /; Abs[x - y] < 3 -> 1}, {10, 10}]

Out[3]=
SparseArray[Automatic, {10, 10}, 0, {1, {{0, 3, 7, 12, 17, 22, 27, 32, 37, 41, 44}, 
   {{1}, {2}, {3}, {4}, {1}, {2}, {3}, {2}, {4}, {1}, {5}, {3}, {4}, {2}, {3}, {6}, {5}, {6}, {3}, 
    {5}, {4}, {7}, {7}, {6}, {5}, {8}, {4}, {6}, {5}, {8}, {7}, {9}, {8}, {10}, {9}, {7}, {6}, {8}, 
    {10}, {9}, {7}, {10}, {9}, {8}}}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}]

In[4]:= CharacteristicPolynomial[%, x]

Out[4]= 1 + 2 x - 15 x^2 - 20 x^3 + 61 x^4 + 28 x^5 - 76 x^6 + 28 x^8 - 10 x^9 + x^10
```

---

Characteristic polynomials of structured matrices:

```wl
In[1]:= SymmetrizedArray[{{1, 1} -> 2, {1, 2} -> 1}, {2, 2}, Symmetric[All]]

Out[1]=
SymmetrizedArray[StructuredArray`StructuredData[{2, 2}, {{{1, 1} -> 2, {1, 2} -> 1}, 
   Symmetric[{1, 2}]}]]

In[2]:= CharacteristicPolynomial[%, x]

Out[2]= -1 - 2 x + x^2

In[3]:= QuantityArray[{{1, 2}, {3, 4}}, {"Meters", "Meters"}]

Out[3]= QuantityArray[StructuredArray`StructuredData[{2, 2}, {{{1, 2}, {3, 4}}, "Meters", {{1}, {2}}}]]

In[4]:= CharacteristicPolynomial[%, x]

Out[4]= x^2 + x (Quantity[-4, "Meters"]) + Quantity[-2, "Meters"^2] + x (Quantity[-1, "Meters"])
```

---

The characteristic polynomial of an identity matrix is a binomial expansion:

```wl
In[1]:= CharacteristicPolynomial[IdentityMatrix[12], λ]

Out[1]= 1 - 12 λ + 66 λ^2 - 220 λ^3 + 495 λ^4 - 792 λ^5 + 924 λ^6 - 792 λ^7 + 495 λ^8 - 220 λ^9 + 66 λ^10 - 12 λ^11 + λ^12

In[2]:= Factor[%]

Out[2]= (-1 + λ)^12
```

---

Characteristic polynomial of ``HilbertMatrix[n]`` :

```wl
In[1]:= CharacteristicPolynomial[HilbertMatrix[5], λ]

Out[1]= (1/266716800000) - (61501 λ/53343360000) + (852401 λ^2/222264000) - (735781 λ^3/2116800) + (563 λ^4/315) - λ^5
```

---

The characteristic polynomial of ``JordanMatrix[λ, n]`` is $(\lambda -x)^n$ :

```wl
In[1]:= CharacteristicPolynomial[JordanMatrix[λ, 4], x] == (λ - x)^4//Simplify

Out[1]= True

In[2]:= CharacteristicPolynomial[JordanMatrix[λ, 5], x] == (λ - x)^5//Simplify

Out[2]= True
```

---

The minimal polynomial of ``CompanionMatrix[{c0, c1, …, cn}}]`` :

```wl
In[1]:= CompanionMatrix[{c0, c1, c2, c3}]//MatrixForm

Out[1]//MatrixForm=
(⁠|   |   |   |     |
| - | - | - | --- |
| 0 | 0 | 0 | -c0 |
| 1 | 0 | 0 | -c1 |
| 0 | 1 | 0 | -c2 |
| 0 | 0 | 1 | -c3 |⁠)

In[2]:= CharacteristicPolynomial[%, x]

Out[2]= c0 + c1 x + c2 x^2 + c3 x^3 + x^4
```

### Applications (6)

Find the characteristic polynomial of the matrix $m$ and compare the behavior for $a<32$, $a=32$ and $a>32$ :

```wl
In[1]:=
m = (|    |     |     |
| -- | --- | --- |
| -6 | 28  | 21  |
| 4  | -15 | -12 |
| -8 | a   | 25  |)

Out[1]= {{-6, 28, 21}, {4, -15, -12}, {-8, a, 25}}

In[2]:= cp = CharacteristicPolynomial[m, x]

Out[2]= -382 + 12 a + 379 x - 12 a x + 4 x^2 - x^3
```

Examining the roots, there is a root at $x=1$ independent of $a$ :

```wl
In[3]:= roots = SolveValues[cp == 0, x]

Out[3]= {1, (1/2) (3 - Sqrt[1537 - 48 a]), (1/2) (3 + Sqrt[1537 - 48 a])}
```

For $a=32$ the root at $x=1$ is repeated:

```wl
In[4]:= roots /. a -> 32

Out[4]= {1, 1, 2}
```

For $a<32$ there are three distinct real roots:

```wl
In[5]:= roots /. a -> 31

Out[5]= {1, -2, 5}
```

And for $a>32$, $x=1$ is the only real root, with the other two roots a complex conjugate pair:

```wl
In[6]:= roots /. a -> 33

Out[6]= {1, (1/2) (3 - I Sqrt[47]), (1/2) (3 + I Sqrt[47])}
```

Visualize the three polynomials, zooming in on the "bounce" of the plot at the double root $x=1$ :

```wl
In[7]:=
{Plot[Table[cp, {a, {32, 31, 33}}]//Evaluate, {x, -3, 6}, PlotLegends -> LineLegend[{a == 32, a == 31, a == 33}], ImageSize -> Small], 
	Plot[cp /. a -> 32, {x, 0.5, 2.5}, PlotLegends -> LineLegend[{a == 32}], ImageSize -> Small]}//Row

Out[7]= [image]
```

---

Compute the determinant of a matrix as the constant term in its characteristic polynomial:

```wl
In[1]:= m = {{6, 5, 8, 1, 4}, {8, 0, 2, 7, 1}, {7, 4, 0, 8, 3}, {2, 3, 1, 1, 6}, {0, 4, 8, 2, 3}};

In[2]:= cp = CharacteristicPolynomial[m, x]

Out[2]= -8481 - 1710 x + 638 x^2 + 148 x^3 + 10 x^4 - x^5
```

Substitute in $x=0$ :

```wl
In[3]:= cp /. x -> 0

Out[3]= -8481
```

This result is also the product of the roots of the characteristic polynomial:

```wl
In[4]:= Times @@ SolveValues[cp == 0, x] // FullSimplify

Out[4]= -8481
```

Compare with a direct computation using ``Det`` :

```wl
In[5]:= Det[m]

Out[5]= -8481
```

---

Compute the trace of a matrix as the coefficient of the subleading power term in the characteristic polynomial:

```wl
In[1]:= m = {{4, 3, 8, 9}, {8, 1, 0, 7}, {1, 2, 6, 7}, {2, 5, 1, 2}};

In[2]:= cp = CharacteristicPolynomial[m, x]

Out[2]= -568 - 30 x - 36 x^2 - 13 x^3 + x^4
```

Extract the coefficient of $(-x)^{n-1}$, where $n$ is the height or width of the matrix:

```wl
In[3]:= (-1)^Length[m] - 1Coefficient[cp, x^Length[m] - 1]

Out[3]= 13
```

This result is also the sum of the roots of the characteristic polynomial:

```wl
In[4]:= Total[SolveValues[cp == 0, x]]//FullSimplify

Out[4]= 13
```

Compare with a direct computation using ``Tr`` :

```wl
In[5]:= Tr[m]

Out[5]= 13
```

---

Find the eigenvalues of a matrix as the roots of the characteristic polynomial:

```wl
In[1]:= m = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};

In[2]:= SolveValues[CharacteristicPolynomial[m, x] == 0, x]

Out[2]= {0, (3/2) (5 - Sqrt[33]), (3/2) (5 + Sqrt[33])}
```

Compare with a direct computation using ``Eigenvalues`` :

```wl
In[3]:= Eigenvalues[m]

Out[3]= {(3/2) (5 + Sqrt[33]), (3/2) (5 - Sqrt[33]), 0}
```

---

Use the characteristic polynomial to find the eigenvalues and eigenvectors of the matrices $a$ and $a^T$ :

```wl
In[1]:= a = {{3, 9, 4}, {3, 7, 1}, {8, 1, 8}};

In[2]:= cp = CharacteristicPolynomial[a, x]

Out[2]= -191 - 41 x + 18 x^2 - x^3
```

The two matrices have the same characteristic polynomial:

```wl
In[3]:= CharacteristicPolynomial[Transpose[a], x] == cp

Out[3]= True
```

Thus, they will both have the same eigenvalues, which are the roots of the polynomial:

```wl
In[4]:= λ = SolveValues[cp == 0, x]

Out[4]= {Root[191 + 41*#1 - 18*#1^2 + #1^3 & , 1, 0], Root[191 + 41*#1 - 18*#1^2 + #1^3 & , 2, 0], Root[191 + 41*#1 - 18*#1^2 + #1^3 & , 3, 0]}
```

The eigenvectors are given by the null space of $a-\lambda I$ :

```wl
In[5]:= Subscript[v, λ] = Join[NullSpace[a - λ[[1]]IdentityMatrix[3]], NullSpace[a - λ[[2]]IdentityMatrix[3]], NullSpace[a - λ[[3]]IdentityMatrix[3]]]//FullSimplify

Out[5]= {{Root[-101 - 504*#1 + 473*#1^2 + 605*#1^3 & , 1, 0], Root[43 - 147*#1 - 154*#1^2 + 605*#1^3 & , 2, 0], 1}, {Root[-101 - 504*#1 + 473*#1^2 + 605*#1^3 & , 2, 0], Root[43 - 147*#1 - 154*#1^2 + 605*#1^3 & , 1, 0], 1}, {Root[-101 - 504*#1 + 473*#1^2 + 605*#1^3 & , 3, 0], Root[43 - 147*#1 - 154*#1^2 + 605*#1^3 & , 3, 0], 1}}
```

``Eigensystem`` gives the same result, though it sorts eigenvalues by absolute value:

```wl
In[6]:= Eigensystem[a]

Out[6]= {{Root[191 + 41*#1 - 18*#1^2 + #1^3 & , 3, 0], Root[191 + 41*#1 - 18*#1^2 + #1^3 & , 2, 0], Root[191 + 41*#1 - 18*#1^2 + #1^3 & , 1, 0]}, {{Root[-101 - 504*#1 + 473*#1^2 + 605*#1^3 & , 3, 0], Root[43 - 147*#1 - 154*#1^2 + 605*#1^3 & , 3, 0], 1}, {Root[-101 - 504*#1 + 473*#1^2 + 605*#1^3 & , 2, 0], Root[43 - 147*#1 - 154*#1^2 + 605*#1^3 & , 1, 0], 1}, {Root[-101 - 504*#1 + 473*#1^2 + 605*#1^3 & , 1, 0], Root[43 - 147*#1 - 154*#1^2 + 605*#1^3 & , 2, 0], 1}}}
```

While $a^T$ has the same eigenvalues as $a$, it has different eigenvectors:

```wl
In[7]:= Subsuperscript[v, λ,  * ] = Join[NullSpace[a\[Transpose] - λ[[1]]IdentityMatrix[3]], NullSpace[a\[Transpose] - λ[[2]]IdentityMatrix[3]], NullSpace[a\[Transpose] - λ[[3]]IdentityMatrix[3]]]//FullSimplify

Out[7]= {{Root[31 - 228*#1 + 113*#1^2 + 55*#1^3 & , 1, 0], Root[689 - 381*#1 - 122*#1^2 + 55*#1^3 & , 3, 0], 1}, {Root[31 - 228*#1 + 113*#1^2 + 55*#1^3 & , 2, 0], Root[689 - 381*#1 - 122*#1^2 + 55*#1^3 & , 1, 0], 1}, {Root[31 - 228*#1 + 113*#1^2 + 55*#1^3 & , 3, 0], Root[689 - 381*#1 - 122*#1^2 + 55*#1^3 & , 2, 0], 1}}
```

Visualize the two sets of eigenvectors:

```wl
In[8]:= {MatrixPlot[Subscript[v, λ]], MatrixPlot[Subsuperscript[v, λ,  * ]]}

Out[8]= {[image], [image]}
```

---

Find the generalized eigensystem of $a$ with respect to $b$ as the roots of the characteristic polynomial:

```wl
In[1]:= a = {{1., 1.5, 2.}, {3.1, 2., 2.9}, {3., 2., 1.}};

In[2]:= b = {{1.3, .5, 1.1}, {0., 1.5, 2.3}, {1., 0., 1.}};

In[3]:= CharacteristicPolynomial[{a, b}, x]

Out[3]= 5.  + 5.97 x - 3.28 x^2 - 1.45 x^3
```

The roots of the generalized characteristic polynomial are the generalized eigenvalues:

```wl
In[4]:= λ = SolveValues[% == 0, x]

Out[4]= {-3.21004, -0.665698, 1.61367}
```

The generalized eigenvectors are given by the null space of $a-\lambda b$ :

```wl
In[5]:= Subscript[v, λ] = Join[NullSpace[a - λ[[1]]b], NullSpace[a - λ[[2]]b], NullSpace[a - λ[[3]]b]]//FullSimplify

Out[5]= {{-0.12925, -0.808178, 0.57458}, {0.305115, -0.87407, 0.378029}, {0.265603, 0.109783, 0.957811}}
```

Compare with a direct computation using ``Eigensystem`` :

```wl
In[6]:= Eigensystem[{a, b}]

Out[6]= {{-3.21004, 1.61367, -0.665698}, {{-0.12925, -0.808178, 0.57458}, {-0.265603, -0.109783, -0.957811}, {-0.305115, 0.87407, -0.378029}}}
```

### Properties & Relations (10)

The characteristic polynomial is equivalent to ``Det[m - id x]`` :

```wl
In[1]:= m = RandomInteger[9, {10, 10}];

In[2]:= cp = CharacteristicPolynomial[m, x]

Out[2]= 307960090 + 150589872 x - 30349953 x^2 - 7786386 x^3 + 2056940 x^4 + 6398 x^5 - 36248 x^6 + 2905 x^7 + 12 x^8 - 49 x^9 + x^10

In[3]:= % == Det[m - IdentityMatrix[Length[m]] x]

Out[3]= True
```

---

The generalized characteristic polynomial is equivalent to ``Det[m - a x]`` :

```wl
In[1]:= {m, a} = RandomInteger[9, {2, 5, 5}];

In[2]:= CharacteristicPolynomial[{m, a}, x]

Out[2]= -176 + 15012 x - 20780 x^2 + 7604 x^3 - 4680 x^4 - 1880 x^5

In[3]:= % == Det[m - a x]

Out[3]= -783 + 79 x - 2671 x^2 + 16020 x^3 - 26327 x^4 + 9390 x^5
```

---

A matrix is a root of its characteristic polynomial (Cayley–Hamilton theorem [[more...](http://mathworld.wolfram.com/Cayley-HamiltonTheorem.html)]):

```wl
In[1]:=
m = RandomInteger[10, {10, 10}];
cp = CharacteristicPolynomial[m, x];
MatrixPolynomialValue[cp, m, x] == ConstantArray[0, {10, 10}]

Out[1]= True

In[2]:= MatrixPolynomialValue[cp, m, x]//AbsoluteTiming

Out[2]= {0.000302, {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}}
```

---

$\prod _{\text{\textit{$i$}}=1}^{\text{\textit{$n$}}} \left(\text{\textit{$v$}}_{\text{\textit{$i$}}}-\text{\textit{$x$}}\right)$ where $v_i$ are the eigenvalues is equivalent to the characteristic polynomial:

```wl
In[1]:= m = RandomReal[1, {10, 10}];

In[2]:= Product[(v - x), {v, Eigenvalues[m]}] - CharacteristicPolynomial[m, x]//Simplify//Chop

Out[2]= 0
```

---

The sum of the roots of the characteristic polynomial is the trace (``Tr``) of the matrix:

```wl
In[1]:= m = RandomReal[1, {10, 10}];

In[2]:= roots = SolveValues[CharacteristicPolynomial[m, x] == 0, x];

In[3]:= Total[roots] == Tr[m]

Out[3]= True
```

Similarly, the product of the roots is the determinant (``Det``):

```wl
In[4]:= Times @@ roots == Det[m]

Out[4]= True
```

---

A matrix and its transpose have the same characteristic polynomial:

```wl
In[1]:= m = RandomReal[1, {10, 10}];

In[2]:= CharacteristicPolynomial[m, x] == CharacteristicPolynomial[Transpose[m], x]

Out[2]= True
```

---

All triangular matrices with a common diagonal have the same characteristic polynomial:

```wl
In[1]:=
t1 = (|   |   |   |
| - | - | - |
| 1 | 0 | 0 |
| 0 | 1 | 0 |
| 0 | 0 | 1 |);t2 = (|   |   |   |
| - | - | - |
| 1 | 4 | 0 |
| 0 | 1 | 3 |
| 0 | 0 | 1 |);t3 = (|   |   |   |
| - | - | - |
| 1 | 0 | 0 |
| 5 | 1 | 0 |
| 6 | 7 | 1 |);

In[2]:= CharacteristicPolynomial[t1, x] == CharacteristicPolynomial[t2, x] == CharacteristicPolynomial[t3, x]

Out[2]= True
```

---

If $p(x)$ is a monic polynomial, then the characteristic polynomial of its companion matrix is $p(x)$ :

```wl
In[1]:=
cl = RandomInteger[9, 10];
p = cl.x ^ Range[0, 9] + x ^ 10

Out[1]= 5 + 8 x + 9 x^2 + 3 x^3 + 7 x^4 + 3 x^5 + 4 x^7 + x^8 + 2 x^9 + x^10

In[2]:= CharacteristicPolynomial[CompanionMatrix[cl], x] == p

Out[2]= True
```

---

``MatrixMinimalPolynomial[m, λ]`` divides ``CharacteristicPolynomial[m, λ]`` with a (possibly constant) polynomial quotient:

```wl
In[1]:=
mat = (⁠|   |    |    |
| - | -- | -- |
| 0 | -1 | 1  |
| 1 | 2  | -1 |
| 1 | 1  | 0  |⁠);
PolynomialQuotientRemainder[CharacteristicPolynomial[mat, t], MatrixMinimalPolynomial[mat, t], t]

Out[1]= {1 - t, 0}
```

---

The minimal polynomial and the characteristic polynomial have the same distinct roots:

```wl
In[1]:=
a = (|    |    |   |   |
| -- | -- | - | - |
| -6 | 4  | 0 | 9 |
| -3 | 0  | 1 | 6 |
| -1 | -2 | 1 | 0 |
| -4 | 4  | 0 | 7 |);
χ = CharacteristicPolynomial[a, λ];
μ = MatrixMinimalPolynomial[a, λ];
Roots[μ == 0, λ] == DeleteDuplicates[Roots[χ == 0, λ]]

Out[1]= True
```

In particular, this means $\chi$ divides $\mu$ raised to the $\text{lcm}(\deg (\mu ),\deg (\chi ))$ power:

```wl
In[2]:= PolynomialRemainder[μ ^ LCM@@(Max@Cases[#, λ ^ k_ :> k, -1]& /@ {μ, χ}), χ, λ]

Out[2]= 0
```

## See Also

* [`Eigenvalues`](https://reference.wolfram.com/language/ref/Eigenvalues.en.md)
* [`Det`](https://reference.wolfram.com/language/ref/Det.en.md)
* [`Eigensystem`](https://reference.wolfram.com/language/ref/Eigensystem.en.md)

## Tech Notes

* [Basic Matrix Operations](https://reference.wolfram.com/language/tutorial/LinearAlgebra.en.md#25697)
* [Eigenvalues and Eigenvectors](https://reference.wolfram.com/language/tutorial/LinearAlgebra.en.md#9501)

## Related Guides

* [Matrix Operations](https://reference.wolfram.com/language/guide/MatrixOperations.en.md)
* [Finite Fields](https://reference.wolfram.com/language/guide/FiniteFields.en.md)

## History

* Introduced in 2003 (5.0) \| [Updated in 2007 (6.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn60.en.md) ▪ [2024 (14.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn140.en.md)