Yet another way to get the companion matrix:
coeff = Array[a, 4, 0];
mat = ReplacePart[
DiagonalMatrix[ConstantArray[1, Length@coeff - 1], 1],
-1 -> -coeff]
$$\left(
\begin{array}{cccc}
0 & 1 & 0 & 0 \\
0 & 0 & 1 & 0 \\
0 & 0 & 0 & 1 \\
-a(0) & -a(1) & -a(2) & -a(3) \\
\end{array}
\right)$$
There is a formula for the inverse:
imat = ReplacePart[
DiagonalMatrix[ConstantArray[1, Length@coeff - 1], -1],
1 -> -RotateLeft@ReplacePart[coeff, 1 -> 1]/First[coeff]]
$$\left(
\begin{array}{cccc}
-\frac{a(1)}{a(0)} & -\frac{a(2)}{a(0)} & -\frac{a(3)}{a(0)} & -\frac{1}{a(0)} \\
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 1 & 0 \\
\end{array}
\right)$$
Check:
mat.imat == IdentityMatrix[Length@coeff]
(* True *)
From my comment, an internal function:
NRoots`CompanionMatrix[Append[{a0, a1, a2, a3, a4}, 1]]
Or if starting from a monic polynomial:
NRoots`CompanionMatrix[
CoefficientList[a0 + a1 x + a2 x^2 + a3 x^3 + a4 x^4 + x^5]]
NRoots`CompanionMatrix[Append[{a0, a1, a2, a3, a4}, 1]]orNRoots`CompanionMatrix[CoefficientList[a0 + a1 x + a2 x^2 + a3 x^3 + a4 x^4 + x^5]]if starting from a monic polynomial. – Michael E2 Nov 08 '20 at 16:31