Previous Page Next Page Contents

poly -- create a polynomial

Introduction

poly(f) converts a polynomial expression f to a polynomial of the kernel domain DOM_POLY.

Call(s)

poly(f <, [x1, x2...]> <, ring>)
poly(p <, [x1, x2...]> <, ring>)
poly(list, [x1, x2...] <, ring>)

Parameters

f - a polynomial expression
x1, x2... - the indeterminates of the polynomial: typically, identifiers or indexed identifiers.
ring - the coefficient ring: either Expr, or IntMod(n) with some integer n > 1, or a domain of type DOM_DOMAIN. The default is the ring Expr of arbitrary MuPAD expressions.
p - a polynomial of type DOM_POLY generated by poly
list - a list containing coefficients and exponents

Returns

a polynomial of the domain type DOM_POLY. FAIL is returned if conversion to a polynomial is not possible.

Related Functions

Dom::DistributedPolynomial, Dom::MultivariatePolynomial, Dom::Polynomial, Dom::UnivariatePolynomial, RootOf, coeff, collect, degree, degreevec, divide, evalp, expr, factor, gcd, ground, indets, lcoeff, ldegree, lmonomial, lterm, mapcoeffs, nterms, nthcoeff, nthmonomial, nthterm, poly2list, polylib, tcoeff

Details

Option: ring

Example 1

A call of poly creates a polynomial from a polynomial expression:

>> p := poly(2*x*(x + 3))
                                   2
                           poly(2 x  + 6 x, [x])

The operators *, +, - and ^ work on polynomials:

>> p^2 - p + poly(x, [x])
                           4       3       2
                   poly(4 x  + 24 x  + 34 x  - 5 x, [x])

For multiplication with a constant, one must either convert the constant to a polynomial of the appropriate type, or one can use multcoeffs:

>> poly(c, [x])*p = multcoeffs(p, c)
                   2                               2
       poly((2 c) x  + (6 c) x, [x]) = poly((2 c) x  + (6 c) x, [x])
>> delete p:

Example 2

A polynomial may be created with parameters. In the following call, y is a parameter and not an indeterminate:

>> poly((x*(y + 1))^2, [x])
                                      2  2
                          poly((y + 1)  x , [x])

If no indeterminates are specified, they are searched for automatically. In the following call, the previous expression is converted to a multivariate polynomial:

>> poly((x*(y + 1))^2)
                           2  2        2    2
                     poly(y  x  + 2 y x  + x , [y, x])

The order of the indeterminates can be specified explicitly:

>> poly((x*(y + 1))^2, [x, y])
                           2  2      2      2
                     poly(x  y  + 2 x  y + x , [x, y])

Example 3

The following polynomials are created by term lists:

>> poly([[c2, 3], [c1, 7], [c3, 0]], [x])
                                7       3
                       poly(c1 x  + c2 x  + c3, [x])
>> poly([[c2, 3], [c1, 7], [c3, 0], [a, 3]], [x])
                             7             3
                    poly(c1 x  + (a + c2) x  + c3, [x])

For multivariate polynomials, exponent vectors must be specified via lists:

>> poly([[c1, [2, 2]], [c2, [2, 1]], [c3, [2, 0]]], [x, y])
                          2  2       2         2
                 poly(c1 x  y  + c2 x  y + c3 x , [x, y])

Example 4

Expressions such as f(x) may be used as indeterminates:

>> poly(f(x)*(f(x) + x^2))
                           2            2
                     poly(x  f(x) + f(x) , [x, f(x)])

Example 5

The residue class ring IntMod(7) is a valid coefficient ring:

>> p := poly(9*x^3 + 4*x - 7, [x], IntMod(7))
                             3
                     poly(2 x  - 3 x, [x], IntMod(7))

Internally, modular arithmetic is used when computing with polynomials over this ring:

>> p^3
                       9    7      5    3
                 poly(x  - x  - 2 x  + x , [x], IntMod(7))

Note, however, that coefficients are not returned as elements of a special domain, but as plain integers of type DOM_INT:

>> coeff(p)
                                   2, -3
>> delete p:

Example 6

The input syntax using term lists may be combined with a given coefficient ring:

>> poly([[9, 3], [4, 1], [-2, 0]], [x], IntMod(7))
                           3
                   poly(2 x  - 3 x - 2, [x], IntMod(7))

Note that the input coefficients are interpreted as elements of the coefficient domain, i.e., conversions such as 9 mod 7 -> 2 occur on input. We can also use the domain Dom::IntegerMod(7) to define an equivalent polynomial. However, in contrast to IntMod(7), the coefficients a represented by the numbers 0,...,6 rather than -3,...,3:

>> poly([[9, 3], [4, 1], [-2, 0]], [x], Dom::IntegerMod(7))
                       3
               poly(2 x  + 4 x + 5, [x], Dom::IntegerMod(7))

Note that the following attempt to define a polynomial via an expression fails, because the domain Dom::IntegerMod(7) does not permit multiplication with identifiers:

>> c := Dom::IntegerMod(7)(3)
                                  3 mod 7
>> poly(c*x^2, [x], Dom::IntegerMod(7))
                                   FAIL

In such a case, term lists allow to specify the polynomial:

>> poly([[c, 2]], [x], Dom::IntegerMod(7))
                            2
                    poly(3 x , [x], Dom::IntegerMod(7))
>> delete c:

Example 7

It is possible to change the indeterminates in a polynomial:

>> p:= poly(((a + b)*x - a^2)*x, [x]): p, poly(p, [a, b])
                    2       2
      poly((a + b) x  + (- a ) x, [x]),
      
                    2    2      2
         poly((-x) a  + x  a + x  b, [a, b])

Example 8

It is possible to change the coefficient ring of a polynomial:

>> p := poly(-4*x + 5*y - 5, [x, y], IntMod(7)):
   p, poly(p, IntMod(3))
      poly(3 x - 2 y + 2, [x, y], IntMod(7)),
      
         poly(y - 1, [x, y], IntMod(3))

Example 9

Here we create a polynomial over the coefficient ring Dom::Float:

>> poly(3*x - y, Dom::Float)          
                 poly(- 1.0 y + 3.0 x, [y, x], Dom::Float)

The identifier y cannot turn up in coefficients from this ring, because it cannot be converted to a floating point number:

>> poly(3*x - y, [x], Dom::Float)
                                   FAIL

Background

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000