linalg::companion -- Companion
matrix of a univariate polynomial
Introductionlinalg::companion(p) returns the companion
matrix associated with the polynomial p.
Call(s)linalg::companion(p <, x>)
Parametersp |
- | an univariate polynomial, or a polynomial expression |
x |
- | an indeterminate |
Returnsa matrix of the domain Dom::Matrix(R).
Detailsp must be monic and of degree one at least.p is a polynomial, i.e., an object of type DOM_POLY, then specifying
x has no effect.p is a polynomial, then the component ring of the
returned matrix is the coefficient ring of p, except in
two cases for built-in 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).p is a polynomial expression, then the companion
matrix is defined over Dom::ExpressionField().p is a polynomial expression containing several
symbolic indeterminates then x must be specified and
distinguishes the indeterminate x from the other symbolic
parameters.
Example
1We start with the following polynomial expression:
>> delete a0, a1, a2, a3: p := x^4 + a3*x^3 + a2*x^2 + a1*x + a0
4 2 3
a0 + x a1 + x + x a2 + x a3
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:
>> linalg::companion(p)
Error: multivariate expression [linalg::companion]
>> linalg::companion(p, x)
+- -+
| 0, 0, 0, -a0 |
| |
| 1, 0, 0, -a1 |
| |
| 0, 1, 0, -a2 |
| |
| 0, 0, 1, -a3 |
+- -+
Of course, we can compute the companion matrix of p with respect to a0 as well:
>> linalg::companion(p, a0)
+- 4 2 3 -+
| - x a1 - x - x a2 - x a3 |
+- -+
The following fails with an error message, because the polynomial p is not monic with respect to a1:
>> linalg::companion(p, a1)
Error: polynomial is not monic [linalg::companion]
Example
2If we enter a polynomial over the built-in 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]))
+- -+
| 0, -PI |
| |
| 1, -10 |
+- -+
>> domtype(C)
Dom::Matrix()
If we define a polynomial over the build-in 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))
2
poly(x + x + 1, [x], IntMod(3))
>> C := linalg::companion(p)
+- -+
| 0 mod 3, 2 mod 3 |
| |
| 1 mod 3, 2 mod 3 |
+- -+
>> domtype(C)
Dom::Matrix(Dom::IntegerMod(3))
Background
+- -+
| 0, 0, .., 0, -a[0] |
| |
| 1, 0, .., 0, -a[1] |
| |
C = | : : : : |.
| |
| 0, 0, .., 0, -a[n-1] |
| |
| 0, 0, .., 1, -a[n] |
+- -+