Nth monomial of a polynomial
This functionality does not run in MATLAB.
nthmonomial(p
,n
) nthmonomial(f
, <vars
>,n
)
nthmonomial(p, n)
returns the n
th
nontrivial monomial of the polynomial p
.
nthmonomial
returns the n
th
nontrivial monomial with respect to the lexicographical ordering.
The "first" monomial is the leading monomial as
returned by lmonomial
.
A zero polynomial has no terms: nthmonomial
returns FAIL
.
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.
The result of nthmonomial
is not fully evaluated.
It can be evaluated by the functions mapcoeffs
and eval
. Cf. Example 2.
We give some self explaining examples:
p := poly(100*x^100 + 49*x^49 + 7*x^7, [x]): nthmonomial(p, 1), nthmonomial(p, 2), nthmonomial(p, 3)
nthmonomial(p, 4)
nthmonomial(poly(0, [x]), 1)
delete p:
We demonstrate the evaluation strategy of nthmonomial
:
p := poly(3*x^3 + 6*x^2*y^2 + 2, [x]): y := 4: nthmonomial(p, 2)
Evaluation is enforced by eval
:
mapcoeffs(%, eval)
delete p, y:

A polynomial of
type 
 

A list of indeterminates of the polynomial: typically, identifiers or indexed identifiers 

A positive integer 
Polynomial of the same type as p
. An expression
is returned if a polynomial expression is given as input. FAIL
is
returned if n
is larger than the actual number
of terms of the polynomial.
p