### 2.46.10 Companion matrix of a polynomial : `companion`

`companion` takes as argument an unitary polynomial *P* and the
name of its variable.

`companion` returns the matrix whose characteristic polynomial is *P*.

If *P*(*x*)=*x*^{n}+*a*_{n−1}*x*^{n−1}+...+*a*_{−1}*x*+*a*_{0},
this matrix is equal to the unit matrix of size *n*−1 bordered with
[0,0..,0,−*a*_{0}] as first row, and with
[−*a*_{0},−*a*_{1},....,−*a*_{n−1}] as last column.

Input :

`companion(x``^`

`2+5x-7,x)`

Output :

`[[0,7],[1,-5]]`

Input :

`companion(x``^`

`4+3x``^`

`3+2x``^`

`2+4x-1,x)`

Output :

`[[0,0,0,1],[1,0,0,-4],[0,1,0,-2],[0,0,1,-3]]`