Companion matrix of a univariate polynomial
MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
linalg::companion(p) returns the companion
matrix associated with the polynomial p.
p must be monic and of degree one at least.
p is a polynomial, i.e., an object of
x has no effect.
p is a polynomial, then the component
ring of the returned matrix is the coefficient ring of
except in two cases for built-in coefficient rings: if the coefficient
Expr then the domain
the component ring of the companion matrix. If it is
the companion matrix is defined over the ring
(m) (see Example 2).
p is a polynomial expression, then the
companion matrix is defined over
p is a polynomial expression containing
several symbolic indeterminates then
x must be
specified and distinguishes the indeterminate
the other symbolic parameters.
We start with the following polynomial expression:
delete a_0, a_1, a_2, a_3: p := x^4 + a_3*x^3 + a_2*x^2 + a_1*x + a_0
To compute the companion matrix of p with
respect to x we
must specify the second parameter x,
because the expression
p contains the indeterminates a0, a1, a2, a3 and x:
Error: Variables in multivariate polynomials must be specified by the second argument. [linalg::companion]
Of course, we can compute the companion matrix of p with respect to a0 as well.
The following fails with an error message, because the polynomial p is not monic with respect to a1:
Error: Polynomial must be monic. [linalg::companion]
If we enter a polynomial over the built-in coefficient domain
then the companion matrix is defined over the standard component ring
for matrices (the domain
C := linalg::companion(poly(x^2 + 10*x + PI, [x]))
If we define a polynomial over the build-in coefficient domain
then the companion matrix is defined over the corresponding component
Dom::IntegerMod(m), as shown in the next example:
p := poly(x^2 + 10*x + 7, [x], IntMod(3))
C := linalg::companion(p)
An univariate polynomial, or a polynomial expression
Matrix of the domain
The companion matrix of the polynomial xn + an1 xn - 1 + … + a1 x + a0 is the matrix:
The companion matrix of a univariate polynomial p of degree n is an n×n matrix C with pC = p, where pC is the characteristic polynomial of C.