Previous Page Next Page Contents

linalg::companion -- Companion matrix of a univariate polynomial

Introduction

linalg::companion(p) returns the companion matrix associated with the polynomial p.

Call(s)

linalg::companion(p <, x>)

Parameters

p - an univariate polynomial, or a polynomial expression
x - an indeterminate

Returns

a matrix of the domain Dom::Matrix(R).

Details

Example 1

We 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 2

If 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

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000