## `tcoeff` -- the trailing coefficient of a polynomial

#### Introduction

`tcoeff(`p`)` returns the trailing coefficient of the polynomial `p`.

#### Call(s)

`tcoeff(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`, `lcoeff`, `ldegree`, `lmonomial`, `lterm`, `nterms`, `nthcoeff`, `nthmonomial`, `nthterm`, `poly`, `poly2list`

#### Details

- The argument `p` can either be a polynomial expression, or a polynomial generated by `poly`, or an element of some polynomial domain overloading `tcoeff`.
- If a list of indeterminates is provided, then `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.
- The returned coefficient is ``trailing'' with respect to the lexicographical ordering, unless a different ordering is specified via the argument `order`. Cf. example 2.
- The result of `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.
- With the ordering LexOrder, `tcoeff` calls a fast kernel function. Other orderings are handled by slower library functions.

#### Example 1

We 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 2

We 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 3

The 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 4

We 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:

#### Changes

- Now it is possible to specify user defined term orderings.
- Indeterminates can now be specified for polynomials of type `DOM_POLY` as well.
- In previous MuPAD releases, `tcoeff` was a kernel function.

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000