# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# `lcoeff`

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

## Syntax

```lcoeff(`p`, <`order`>)
lcoeff(`f`, <`vars`>, <`order`>)
```

## Description

`lcoeff(p)` returns the leading coefficient of the polynomial `p`.

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

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

The result of `lcoeff` is not fully evaluated. Evaluation can be enforced by the function `eval`. Cf. Example 2.

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

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

`lcoeff(p, Dom::MonomOrdering(RevLex(3)))`

`delete p:`

### Example 2

The result of `lcoeff` is not fully evaluated:

```p := poly(a*x^2 + 27*x, [x]): a := 5: lcoeff(p), eval(lcoeff(p))```

`delete p, a:`

### Example 3

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

`lcoeff(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`.

## Return Values

Element of the coefficient domain of the polynomial or `FAIL`.

`p`