charpoly
Characteristic polynomial of a matrix.
Category: Mathematics > Linear Algebra
Syntax
p = charpoly(A)
Returns the coefficients of det(x*I - A), highest power first.
p = charpoly(A, x)
Returns the polynomial itself as an expression in x.
Description
The roots of the characteristic polynomial are the eigenvalues of A. The coefficient vector begins with 1, the second entry is -trace(A) and the last is (-1)^n*det(A). For a symbolic matrix the computation is exact, so the coefficients can contain parameters.
Input arguments
A- Square matrix, numeric or symbolic.
x- Symbolic variable for the polynomial.
Output arguments
p- Coefficient vector (one input) or symbolic polynomial (with
x).
Example
Characteristic polynomial of a 2-by-2 matrix
A = sym([1 2; 3 4]);
charpoly(A)
syms x
charpoly(A, x)
Output
ans =
[1, -5, -2]
ans = x^2 - 5*x - 2