Characteristic polynomial using Hessenberg algorithm

### 15.2.8 Characteristic polynomial using Hessenberg algorithm

The pcar_hessenberg command finds the characteristic polynomial of a matrix. It computes the polynomial using the Hessenberg algorithm1 which is more efficient (O(n3) deterministic) if the coefficients of the matrix are in a finite field or use a finite representation like approximate numeric coefficients. Note however that this algorithm behaves badly if the coefficients are, for example, in ℚ.

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

pcar_hessenberg([[4,1,-2],[1,2,-1],[2,1,0]] % 37)

| ⎡ ⎣ | 1%37, | ⎛ ⎝ | −6 | ⎞ ⎠ | %37,12%37, | ⎛ ⎝ | −8 | ⎞ ⎠ | %37 | ⎤ ⎦

pcar_hessenberg([[4,1,-2],[1,2,-1],[2,1,0]] % 37,x)

| ⎛ ⎝ | 1%37 | ⎞ ⎠ | x3+ | ⎛ ⎝ | ⎛ ⎝ | −6 | ⎞ ⎠ | %37 | ⎞ ⎠ | x2+ | ⎛ ⎝ | 12%37 | ⎞ ⎠ | x+ | ⎛ ⎝ | −8 | ⎞ ⎠ | %37

Hence, the characteristic polynomial of [

4 | 1 | −2
1 | 2 | −1
2 | 1 | 0

] in ℤ/37 ℤ is x3−6x2+12x−8.