This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


N-th term of a polynomial

MuPAD® notebooks are not recommended. 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.


nthterm(p, n)
nthterm(f, <vars>, n)


nthterm(p, n) returns the n-th non-zero term of the polynomialp.

nthterm returns the n-th non-zero term with respect to the lexicographical ordering.

The “first” term is the leading term as returned by lterm.

A zero polynomial has no terms: nthterm returns FAIL.

The identity nthterm(p, n) nthcoeff(p, n) = nthmonomial(p, n) holds.

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.


Example 1

We give some self explaining examples:

p := poly(100*x^100 + 49*x^49 + 7*x^7, [x]):
nthterm(p, 1), nthterm(p, 2), nthterm(p, 3)

nthterm(p, 4)

nthterm(poly(0, [x]), 1)

delete p:

Example 2

The n-th monomial is the product of the n-th coefficient and the n-th term:

p := poly(2*x^2*y + 3*x*y^2 + 6, [x, y]):    
mapcoeffs(nthterm(p, 2), nthcoeff(p, 2)) =
nthmonomial(p, 2)

delete p:



A polynomial of type DOM_POLY


A polynomial expression


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


A positive integer

Return Values

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.

Overloaded By


Was this topic helpful?