# `lmonomial`

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Syntax

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

## Description

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

The returned monomial is “leading” with respect to the lexicographical ordering, unless a different ordering is specified via the argument `order`. Cf. Example 1.

The leading monomial of the zero polynomial is the zero polynomial.

A polynomial expression `f` is first converted to a polynomial with the variables given by `vars`. If no variables are given, they are searched for in `f`. See `poly` about details of the conversion. The result is returned as polynomial expression. `FAIL` is returned if `f` cannot be converted to a polynomial. Cf. Example 4.

The result of `lmonomial` is not fully evaluated. It can be evaluated by the functions `mapcoeffs` and `eval`. Cf. Example 3.

## Examples

### Example 1

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)```
` `

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

`lmonomial(p, Dom::MonomOrdering(RevLex(3)))`
` `
`delete p:`

### Example 2

We compute the reductum of a polynomial:

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

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

`p = q + q`
` `
`delete p, q:`

### Example 3

We demonstrate the evaluation strategy of `lmonomial`:

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

Evaluation is enforced by `eval`:

`mapcoeffs(%, eval)`
` `
`delete p, y:`

### Example 4

The expression `1/x` may not be regarded as polynomial:

`lmonomial(1/x)`
` `

## Parameters

 `p` A polynomial of type `DOM_POLY` `f` `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 two polynomials: the leading monomial and the reductum. The reductum of a polynomial `p` is ```p - lmonomial(p)```.

## Return Values

Polynomial of the same type as `p`. An expression is returned if an expression is given as input. `FAIL` is returned if the input cannot be converted to a polynomial. With `Rem`, a list of two polynomials is returned.

`p`