lterm -- the leading term of a
polynomial
Introductionlterm(p) returns the leading term of the
polynomial p.
Call(s)lterm(p <, vars> <, order>)
Parametersp |
- | 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. |
Returnsa polynomial of the same type as p. An expression is
returned if p is an expression. FAIL is returned if the input cannot be
converted to a polynomial.
p
Related
Functionscoeff, degree, degreevec, ground, lcoeff, ldegree, lmonomial, nterms, nthcoeff, nthmonomial, nthterm, poly, poly2list, tcoeff
Detailsp can either be a polynomial expression,
or a polynomial generated by poly, or an element of some polynomial
domain overloading lterm.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.lterm returns FAIL if the input
polynomial cannot be converted to a polynomial in the specified
indeterminates. Cf. example 3.
Example
1We demonstrate how the indeterminates influence the result:
>> p := 2*x^2*y + 3*x*y^2 + 6: lterm(p), lterm(p, [x, y]), lterm(p, [y, x])
2 2 2
x y , x y, x y
Note that the indeterminates passed to
lterm will be used, even if the polynomial provides
different indeterminates :
>> p := poly(2*x^2*y + 3*x*y^2, [x, y]): lterm(p), lterm(p, [x, y]), lterm(p, [y, x]), lterm(p, [y]), lterm(p, [z])
2 2 2
poly(x y, [x, y]), poly(x y, [x, y]), poly(y x, [y, x]),
2
poly(y , [y]), poly(1, [z])
>> delete p:
Example
2We 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]): lterm(p), lterm(p, DegreeOrder), lterm(p, DegInvLexOrder)
4 3 2
poly(x , [x, y, z]), poly(x y z , [x, y, z]),
2 3
poly(x y z, [x, y, z])
The following call uses the reverse lexicographical order on 3 indeterminates:
>> lterm(p, Dom::MonomOrdering(RevLex(3)))
2 3
poly(x y z, [x, y, z])
>> delete p:
Example
3We define a polynomial over the integers modulo 7:
>> p := poly(3*x + 4, [x], Dom::IntegerMod(7)): lterm(p)
poly(x, [x], Dom::IntegerMod(7))
This polynomial cannot be regarded as a polynomial with
respect to another indeterminate, because the ``coefficient''
x cannot be interpreted as an element of the coefficient
ring Dom::IntegerMod(7):
>> lterm(p, [y])
FAIL
>> delete p:
Example
4The leading monomial is the product of the leading coefficient and the leading term:
>> p := poly(2*x^2*y + 3*x*y^2 + 6, [x, y]): mapcoeffs(lterm(p),lcoeff(p)) = lmonomial(p)
2 2
poly(2 x y, [x, y]) = poly(2 x y, [x, y])
>> delete p:
DOM_POLY as
well.lterm was a kernel
function.