### 15.2.7 Characteristic polynomial

The characteristic polynomial of a square matrix A is the polynomial

P(x)=det(x I−A).

The charpoly or pcar command finds the characteristic polynomial of a matrix.

- charpoly takes one mandatory argument and one or two optional argument(s):
  - A, a square matrix.
  - Optionally, x, a variable name.
  - Optionally, fadeev, the symbol.
- charpoly(A⟨,x⟩) returns the characteristic polynomial of A. It is written as the list of its coefficients if no variable name was provided or written as an expression with respect to x if there is a second argument. If the last argument is fadeev, then charpoly will use the Faddeev–LeVerrier algorithm.

#### Examples

charpoly([[4,1,-2],[1,2,-1],[2,1,0]])

| ⎡ ⎣ | 1,−6,12,−8 | ⎤ ⎦

Hence, the characteristic polynomial of this matrix is x3−6x2+12x−8.

charpoly([[4,1,-2],[1,2,-1],[2,1,0]],X)

X3−6 X2+12 X−8 |  |  |  |  |  |  |  |  |  |