linalg
::companion
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
, <x
>)
linalg::companion(p)
returns the companion
matrix associated with the polynomial p.
p
must be monic and of degree one at least.
If p
is a polynomial, i.e., an object of
type DOM_POLY
,
then specifying x
has no effect.
If p
is a polynomial, then the component
ring of the returned matrix is the coefficient ring of p
,
except in two cases for builtin coefficient rings: if the coefficient
ring of p
is Expr
then the domain Dom::ExpressionField
()
is
the component ring of the companion matrix. If it is IntMod(m)
then
the companion matrix is defined over the ring Dom::IntegerMod
(m)
(see Example 2).
If p
is a polynomial expression, then the
companion matrix is defined over Dom::ExpressionField()
.
If p
is a polynomial expression containing
several symbolic indeterminates then x
must be
specified and distinguishes the indeterminate x
from
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 a_{0}, a_{1}, a_{2}, a_{3} and x:
linalg::companion(p)
Error: Variables in multivariate polynomials must be specified by the second argument. [linalg::companion]
linalg::companion(p, x)
Of course, we can compute the companion matrix of p with respect to a_{0} as well.
linalg::companion(p, a_0)
The following fails with an error message, because the polynomial p is not monic with respect to a_{1}:
linalg::companion(p, a_1)
Error: Polynomial must be monic. [linalg::companion]
If we enter a polynomial over the builtin coefficient domain Expr
,
then the companion matrix is defined over the standard component ring
for matrices (the domain Dom::ExpressionField
()
):
C := linalg::companion(poly(x^2 + 10*x + PI, [x]))
domtype(C)
If we define a polynomial over the buildin coefficient domain IntMod(m)
,
then the companion matrix is defined over the corresponding component
ring Dom::IntegerMod(m)
, as shown in the next example:
p := poly(x^2 + 10*x + 7, [x], IntMod(3))
C := linalg::companion(p)
domtype(C)

An univariate polynomial, or a polynomial expression 

An identifier 
Matrix of the domain Dom::Matrix
(R)
.
The companion matrix of the polynomial x^{n} + a_{n1} x^{n  1} + … + a_{1} x + a_{0} is the matrix:
.
The companion matrix of a univariate polynomial p of degree n is an n×n matrix C with p_{C} = p, where p_{C} is the characteristic polynomial of C.