tcoeff -- the trailing
coefficient of a polynomial
Introductiontcoeff(p) returns the trailing coefficient
of the polynomial p.
Call(s)tcoeff(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. |
Returnsan element of the coefficient domain of the polynomial or FAIL.
p
Related
Functionscoeff, collect, degree, degreevec, ground, lcoeff, ldegree, lmonomial, lterm, nterms, nthcoeff, nthmonomial, nthterm, poly, poly2list
Detailsp can either be a polynomial expression,
or a polynomial generated by poly, or an element of some polynomial
domain overloading tcoeff.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.tcoeff is not fully evaluated.
Evaluation can be enforced by the function eval. Cf. example 3.tcoeff returns FAIL if the input
polynomial cannot be converted to a polynomial in the specified
indeterminates. Cf. example 4.tcoeff calls a fast kernel function. Other orderings are
handled by slower library functions.
Example
1We demonstrate how the indeterminates influence the result:
>> p := 2*x^2*y + 3*x*y^2: tcoeff(p), tcoeff(p, [x, y]), tcoeff(p, [y, x])
2, 3, 2
Note that the indeterminates passed to
tcoeff will be used, even if the polynomial provides
different indeterminates :
>> p := poly(2*x^2*y + 3*x*y^2, [x, y]): tcoeff(p), tcoeff(p, [x, y]), tcoeff(p, [y, x]), tcoeff(p, [y]), tcoeff(p, [z])
2 2 2
3, 3, 2, 2 x , 2 x y + 3 x y
>> delete p:
Example
2We demonstrate how various orderings influence the result:
>> p := poly(5*x^4 + 4*x^3*y + 3*x^2*y^3*z, [x, y, z]): tcoeff(p), tcoeff(p, DegreeOrder), tcoeff(p, DegInvLexOrder)
3, 4, 5
The following call uses the reverse lexicographical order on 3 indeterminates:
>> tcoeff(p, Dom::MonomOrdering(RevLex(3)))
5
>> delete p:
Example
3The result of tcoeff is not fully
evaluated:
>> p := poly(27*x^2 + a*x, [x]): a := 5: tcoeff(p, [x]), eval(tcoeff(p, [x]))
a, 5
>> delete p, a:
Example
4We define a polynomial over the integers modulo 7:
>> p := poly(3*x, [x], Dom::IntegerMod(7)): tcoeff(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):
>> tcoeff(p, [y])
FAIL
>> delete p:
DOM_POLY as
well.tcoeff was a kernel
function.