## `lmonomial` -- the leading monomial of a polynomial

#### Introduction

`lmonomial(`p`)` returns the leading monomial of the polynomial `p`.

#### Call(s)

`lmonomial(p <, vars> <, order> <, Rem>)`

#### 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.

#### Options

`Rem` | - | makes `lmonomial` return a list with the leading monomial and the ``reductum''.

#### Returns

a 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. With Rem, a list of two polynomials is returned.

### Overloadable:

`p`

#### Related Functions

`coeff`, `degree`, `degreevec`, `ground`, `lcoeff`, `ldegree`, `lterm`, `nterms`, `nthcoeff`, `nthmonomial`, `nthterm`, `poly`, `poly2list`, `tcoeff`

#### Details

- The argument `p` can either be a polynomial expression, or a polynomial generated by `poly`, or an element of some polynomial domain overloading `lmonomial`.
- 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 monomial is ``leading'' with respect to the lexicographical ordering, unless a different ordering is specified via the argument `order`. Cf. example 2.
- `lmonomial` returns `FAIL` if the input polynomial cannot be converted to a polynomial in the specified indeterminates. Cf. example 4.
- The result of `lmonomial` is not fully evaluated. It can be evaluated by the functions `mapcoeffs` and `eval`. Cf. example 5.
- The leading monomial of the zero polynomial is the zero polynomial.
- For the orderings LexOrder, DegreeOrder and DegInvLexOrder, the result is computed by a fast kernel function. Other orderings are handled by slower library functions.

#### Option: Rem

- With this option, a list with two polynomials is returned: the leading monomial and the reductum. The reductum of a polynomial `p` is `p - lmonomial(p)`.

#### Example 1

We demonstrate how the indeterminates influence the result:

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

                                   2     2         2
                              3 x y , 2 x  y, 3 x y

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

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

                  2                     2
          poly(2 x  y, [x, y]), poly(2 x  y, [x, y]),

                     2                         2
             poly(3 y  x, [y, x]), poly((3 x) y , [y]),

                     2          2
             poly(2 x  y + 3 x y , [z])

    >> 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]):
       lmonomial(p), lmonomial(p, DegreeOrder),
       lmonomial(p, DegInvLexOrder)

                  4                      3    2
          poly(5 x , [x, y, z]), poly(4 x  y z , [x, y, z]),

                     2  3
             poly(3 x  y  z, [x, y, z])

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

    >> lmonomial(p, Dom::MonomOrdering(RevLex(3)))

                                    2  3
                            poly(3 x  y  z, [x, y, z])

    >> delete p:

#### Example 3

We compute the reductum of a polynomial:

    >> p := poly(2*x^2*y + 3*x*y^2 + 6, [x, y]):
       q := lmonomial(p, Rem)

                          2                       2
                 [poly(2 x  y, [x, y]), poly(3 x y  + 6, [x, y])]

The leading monomial and the reductum add up to the polynomial `p`:

    >> p = q[1] + q[2]

                  2          2
          poly(2 x  y + 3 x y  + 6, [x, y]) =

                     2          2
             poly(2 x  y + 3 x y  + 6, [x, y])

    >> delete p, q:

#### Example 4

We define a polynomial over the integers modulo 7:

    >> p := poly(3*x + 4, [x], Dom::IntegerMod(7)): lmonomial(p)

                        poly(3 x, [x], Dom::IntegerMod(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)`:

    >> lmonomial(p, [y])

                                       FAIL

    >> delete p:

#### Example 5

We demonstrate the evaluation strategy of `lmonomial`:

    >> p := poly(6*x^6*y^2 + x^2 + 2, [x]): y := 4: lmonomial(p)

                                        2   6
                               poly((6 y ) x , [x])

Evaluation is enforced by `eval`:

    >> mapcoeffs(%, eval)

                                          6
                                 poly(96 x , [x])

    >> delete p, y:

#### 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, `lmonomial` was a kernel function.

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