This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Characteristic polynomial of a matrix

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.


linalg::charpoly(A, x)


linalg::charpoly(A, x) computes the characteristic polynomial of the matrix A. The characteristic polynomial of a n×n matrix is defined by , where In denotes the n×n identity matrix.

The component ring of A must be a commutative ring, i.e., a domain of category Cat::CommutativeRing.


Example 1

We define a matrix over the rational numbers:

A := Dom::Matrix(Dom::Rational)([[1, 2], [3, 4]])

Then the characteristic polynomial pA(x) is given by:

linalg::charpoly(A, x)

It is of the domain type:


Example 2

We define a matrix over 7:

B := Dom::Matrix(Dom::IntegerMod(7))([[1, 2], [3, 0]])

The characteristic polynomial pB(x) of B is given by:

p := linalg::charpoly(B, x)

We compute the zeros of pB(x), i.e., the eigenvalues of the matrix B:




A square matrix of a domain of category Cat::Matrix


An identifier

Return Values

Polynomial of the domain Dom::DistributedPolynomial([x],R), where R is the component ring of A.


Reference: Jounaidi Abdeljaoued, The Berkowitz Algorithm, Maple and Computing the Characteristic Polynomial in an Arbitrary Commutative Ring, MapleTech Vol 4 No 3, pp 21-32, Birkhäuser, 1997.


linalg::charpoly implements Hessenberg's algorithm to compute the characteristic polynomial of a square matrix A. See: Henri Cohen: A Course in Computational Algebraic Number Theory, GTM 138, Springer Verlag.

This algorithm works for any field and requires only O(n3) field operations, in contrast to O(n4) when computing the determinant of the characteristic matrix of A.

Since the size of the components of A in intermediate computations of Hessenberg's algorithm can swell extremely, it is only applied for matrices over Dom::Float and Dom::IntegerMod.

For any other component ring, the characteristic polynomial is computed using the Berkowitz algorithm.

Was this topic helpful?