Previous Page Next Page Contents

lcoeff -- the leading coefficient of a polynomial

Introduction

lcoeff(p) returns the leading coefficient of the polynomial p.

Call(s)

lcoeff(p <, vars> <, order>)

Parameters

p - a polynomial of type DOM_POLY or a polynomial expression
vars - a list of indeterminates of the polynomial: typically, identifiers or indexed identifiers
order - the term ordering: either LexOrder, or DegreeOrder, or DegInvLexOrder, or a user-defined term ordering of type Dom::MonomOrdering. The default is the lexicographical ordering LexOrder.

Returns

an element of the coefficient domain of the polynomial or FAIL.

Overloadable:

p

Related Functions

coeff, collect, degree, degreevec, ground, ldegree, lmonomial, lterm, nterms, nthcoeff, nthmonomial, nthterm, poly, poly2list, tcoeff

Details

Example 1

We demonstrate how the indeterminates influence the result:

>> p := 2*x^2*y + 3*x*y^2 + 6:
   lcoeff(p), lcoeff(p, [x, y]), lcoeff(p, [y, x])
                                  3, 2, 3

Note that the indeterminates passed to lcoeff will be used, even if the polynomial provides different indeterminates :

>> p := poly(2*x^2*y + 3*x*y^2, [x, y]):    
   lcoeff(p), lcoeff(p, [x, y]), lcoeff(p, [y, x]),
   lcoeff(p, [y]), lcoeff(p, [z])
                                        2          2
                       2, 2, 3, 3 x, 2 x  y + 3 x y
>> delete p:

Example 2

We demonstrate how various orderings influence the result:

>> p := poly(5*x^4 + 4*x^3*y*z^2 + 3*x^2*y^3*z + 2, [x, y, z]):
   lcoeff(p), lcoeff(p, DegreeOrder), lcoeff(p, DegInvLexOrder)
                                  5, 4, 3

The following call uses the reverse lexicographical order on 3 indeterminates:

>> lcoeff(p, Dom::MonomOrdering(RevLex(3)))
                                     3
>> delete p:

Example 3

The result of lcoeff is not fully evaluated:

>> p := poly(a*x^2 + 27*x, [x]): a := 5:
   lcoeff(p, [x]), eval(lcoeff(p, [x]))
                                   a, 5
>> delete p, a:

Example 4

We define a polynomial over the integers modulo 7:

>> p := poly(3*x, [x], Dom::IntegerMod(7)): lcoeff(p)
                                  3 mod 7

This polynomial cannot be regarded as a polynomial with respect to another indeterminate, because the ``coefficient'' 3*x cannot be interpreted as an element of the coefficient ring Dom::IntegerMod(7):

>> lcoeff(p, [y])
                                   FAIL
>> delete p:

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000