Characteristic polynomial: charpoly

### 5.48.7 Characteristic polynomial: charpoly

The characteristic polynomial of a square matrix A is the polynomial

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

The charpoly command finds the characteristic polynomial of a matrix.
pcar is a synonym for charpoly.

- charpoly takes one mandatory argument and one optional argument:
  - A, a square matrix.
  - Optionally, x, a variable name.
- 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.

#### Examples.

- Input:
  charpoly([[4,1,-2],[1,2,-1],[2,1,0]])
  Output:

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

  Hence, the characteristic polynomial of this matrix is x3−6x2+12x−8.
- Input:
  charpoly([[4,1,-2],[1,2,-1],[2,1,0]],X)
  Output:

  X3−6 X2+12 X−8