lcoeff
-- the leading coefficient
of a polynomiallcoeff(
p)
returns the leading coefficient
of the polynomial p
.
lcoeff(p <, vars> <, order>)
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. |
an element of the coefficient domain of the polynomial or FAIL
.
p
coeff
, collect
, degree
, degreevec
, ground
, ldegree
, lmonomial
, lterm
, nterms
, nthcoeff
, nthmonomial
, nthterm
, poly
, poly2list
, tcoeff
p
can either be a polynomial expression,
or a polynomial generated by poly
, or an element of some polynomial
domain overloading lcoeff
.p
is
regarded as a polynomial in these indeterminates. Note that the
specified list does not have to coincide with the indeterminates of the
input polynomial. Cf. example 1.order
. Cf. example 2.lcoeff
is not fully evaluated.
Evaluation can be enforced by the function eval
. Cf. example 3.lcoeff
returns FAIL
if the input
polynomial cannot be converted to a polynomial in the specified
indeterminates. Cf. example 4.lcoeff
calls a fast kernel function. Other orderings are
handled by slower library functions.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:
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:
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:
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:
DOM_POLY
as
well.lcoeff
was a kernel
function.