Tool to calculate the characteristic polynomial of a matrix. The characteristic polynomial of a matrix M is computed as the determinant of (X.I-M).
Characteristic Polynomial of a Matrix - dCode
Tag(s) : Matrix
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
The characteristic polynomial (or sometimes secular function) $ P $ of a square matrix $ M $ of size $ n \times n $ is the polynomial defined by $$ P_M(x) = \det(M - x.I_n) \tag{1} $$ or $$ P_M(x) = \det(x.I_n - M) \tag{2} $$ with $ I_n $ the identity matrix of size $ n $ (and det the matrix determinant).
The 2 possible values $ (1) $ and $ (2) $ give opposite results, but since the polynomial is used to find roots, the sign does not matter.
The equation $ P = 0 $ is called the characteristic equation of the matrix.
The characteristic polynomial $ P $ of a matrix, as its name indicates, characterizes a matrix, it allows in particular to calculate the eigenvalues and the eigenvectors.
If $ M $ is a diagonal matrix with $ \lambda_1, \lambda_2, \ldots, \lambda_n $ as diagonal elements, then the computation is simplified and $$ P_M(x) = (x-\lambda_1)(x-\lambda_2)\ldots(x-\lambda_n) $$
If $ M $ is a triangular matrix with $ \lambda_1, \lambda_2, \ldots, \lambda_n $ as diagonal elements, then as for diagonal matrix, the computation is simplified and $$ P_M(x) = (x-\lambda_1)(x-\lambda_2)\ldots(x-\lambda_n) $$
The calculation of the characteristic polynomial of a square matrix of order 2 can be calculated with the determinant of the matrix $ [ x.I_2 - M ] $ as $$ P_M(x) = \det [ x.I_2 - M ] $$
The polynomial can also be written with another formula using the trace of the matrix $ M $ (noted Tr): $$ P_{M_2}(x) = \det( x.I_2 - M ) = x^2 - \operatorname{Tr}(M)x+ \det(M) $$
Example: $$ M=\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \\ \Rightarrow x.I_n - M = \begin{bmatrix} x & 0 \\ 0 & x \end{bmatrix} - \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} = \begin{bmatrix} x-1 & -2 \\ -3 & x-4 \end{bmatrix} \\ \Rightarrow \det(x.I_n - M) = (x-1)(x-4)-((-2)\times(-3)) \\ \Rightarrow P_M(x) = x^2-5x-2 $$
Calculation of the characteristic polynomial of a square 3x3 matrix can be calculated with the determinant of the matrix $ [ x.I_3 - M ] $ as $$ P_M(x) = \det [ x.I_3 - M ] $$
Example: $$ M = \begin{bmatrix} a & b & c \\ d & e & f \\ g & h & i \end{bmatrix} $$ $$ [ x.I_3 - M ] = x \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} - M = \begin{bmatrix} x-a & -b & -c \\ -d & x-e & -f \\ -g & -h & x-i \end{bmatrix} $$ $$ P_M(x) = \det [ x.I_3 - M ] = -a e i+a e x+a f h+a i x-a x^2+b d i-b d x-b f g-c d h+c e g-c g x+e i x-e x^2-f h x-i x^2+x^3 $$
It is also possible to use another formula with the Trace of the matrix $ M $ (noted Tr): $$ P_{M_3}(x) = -x^3 + \operatorname{Tr}(M)x^2 + \frac{1}{2} \left( \operatorname{Tr}^2(M) - \operatorname{Tr}(M^2) \right) x + \frac{1}{6} \left( \operatorname{Tr}^3(M) + 2\operatorname{Tr}(M^3) - 3\operatorname{Tr}(M)\operatorname{Tr}(M^2) \right) $$
Calculation of the characteristic polynomial of an order 4 square matrix can be calculated with the determinant of the matrix $ [ x.I_4 - M ] $ as $$ P_M(x) = \det [ x.I_4 - M ] $$
Example: $$ M = \begin{bmatrix} a & b & c & d \\ e & f & g & h \\ i & j & k & l \\ m & n & o & p \end{bmatrix} $$ $$ [ x.I_4 - M ] = x \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} - M = \begin{bmatrix} x-a & b & c & d \\ e & x-f & g & h \\ i & j & x-k & l \\ m & n & o & x-p \end{bmatrix} $$ $$ P_M(x) = \det [ x.I_4 - M ] = a f k p-a f k x-a f l o-a f p x+a f x^2-a g j p+a g j x+a g l n+a h j o-a h k n+a h n x-a k p x+a k x^2+a l o x+a p x^2-a x^3-b e k p+b e k x+b e l o+b e p x-b e x^2+b g i p-b g i x-b g l m-b h i o+b h k m-b h m x+c e j p-c e j x-c e l n-c f i p+c f i x+c f l m+c h i n-c h j m+c i p x-c i x^2-c l m x-d e j o+d e k n-d e n x+d f i o-d f k m+d f m x-d g i n+d g j m-d i o x+d k m x-d m x^2-f k p x+f k x^2+f l o x+f p x^2-f x^3+g j p x-g j x^2-g l n x-h j o x+h k n x-h n x^2+k p x^2-k x^3-l o x^2-p x^3+x^4 $$
The characteristic polynomial is unique for a given matrix. There is only one way to calculate it and it has only one result.
On the other hand, two different matrices can give the same characteristic polynomial.
A matrix $ M $ and its matrix transpose $ M^T $ have the same characteristic polynomial.
dCode retains ownership of the "Characteristic Polynomial of a Matrix" source code. Any algorithm for the "Characteristic Polynomial of a Matrix" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Characteristic Polynomial of a Matrix" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Characteristic Polynomial of a Matrix" or any other element are not public (except explicit open source licence like Creative Commons). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.
The content of the page "Characteristic Polynomial of a Matrix" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source.
Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).
To cite dCode.fr on another website, use the link:
In a scientific article or book, the recommended bibliographic citation is: Characteristic Polynomial of a Matrix on dCode.fr [online website], retrieved on 2025-04-16,