# Related Matrices

The *companion matrix* of a monic linear differential operator

$$
D^n+a_{n-1}D^{n-1}+\cdots+a_0 \in F[D]
$$

is defined as the $n\times n$ matrix

$$
 \begin{pmatrix}0&1&0&0&\ldots&0\\ 0&0&1&0&\ldots&0\\ \vdots&\vdots&\vdots&\vdots&\ddots&\vdots\\ 0&0&0&0&\ldots&1\\ -a_0&-a_1&-a_2&-a_3&\ldots&-a_{n-1}\end{pmatrix}
$$

## `CompanionMatrix(L): RngDiffOpElt -> AlgMatElt`

Returns the companion matrix of the monic differential operator $L$.

## `Example Companion Matrix (ex-62793f)`

```magma
> F<z> := RationalDifferentialField(Rationals());
> R<D> := DifferentialOperatorRing(F);
> L := D^3-z*D^2+2*D+5;
> CompanionMatrix(L);
[0 1 0]
[0 0 1]
[-5 -2 z]

```
