charpoly

Characteristic polynomial of matrix

Syntax

charpoly(A)
charpoly(A,var)

Description

example

charpoly(A) returns a vector of coefficients of the characteristic polynomial of A. If A is a symbolic matrix, charpoly returns a symbolic vector. Otherwise, it returns a vector of double-precision values.

example

charpoly(A,var) returns the characteristic polynomial of A in terms of var.

Examples

collapse all

Compute the coefficients of the characteristic polynomial of A by using charpoly.

A = [1 1 0; 0 1 0; 0 0 1];
charpoly(A)
ans =
     1    -3     3    -1

For symbolic input, charpoly returns a symbolic vector instead of double. Repeat the calculation for symbolic input.

A = sym(A);
charpoly(A)
ans =
[ 1, -3, 3, -1]

Compute the characteristic polynomial of the matrix A in terms of x.

syms x
A = sym([1 1 0; 0 1 0; 0 0 1]);
polyA = charpoly(A,x)
polyA =
x^3 - 3*x^2 + 3*x - 1

Solve the characteristic polynomial for the eigenvalues of A.

eigenA = solve(polyA)
eigenA =
 1
 1
 1

Input Arguments

collapse all

Input, specified as a numeric or symbolic matrix.

Polynomial variable, specified as a symbolic variable.

More About

collapse all

Characteristic Polynomial of Matrix

The characteristic polynomial of an n-by-n matrix A is the polynomial pA(x), defined as follows.

pA(x)=det(xInA)

Here, In is the n-by-n identity matrix.

References

[1] Cohen, H. “A Course in Computational Algebraic Number Theory.” Graduate Texts in Mathematics (Axler, Sheldon and Ribet, Kenneth A., eds.). Vol. 138, Springer, 1993.

[2] Abdeljaoued, J. “The Berkowitz Algorithm, Maple and Computing the Characteristic Polynomial in an Arbitrary Commutative Ring.” MapleTech, Vol. 4, Number 3, pp 21–32, Birkhauser, 1997.

Introduced in R2012b