N-th non-zero coefficient of a polynomial
This functionality does not run in MATLAB.
nthcoeff(p, n) nthcoeff(f, <vars>, n)
nthcoeff(p, n) returns the n-th non-zero coefficient of the polynomial p.
nthcoeff returns the n-th non-zero coefficient with respect to the lexicographical ordering.
A zero polynomial has no terms: nthcoeff 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. FAIL is returned if f cannot be converted to a polynomial.
We give some self explaining examples:
p := poly(100*x^100 + 49*x^49 + 7*x^7, [x]): nthcoeff(p, 1), nthcoeff(p, 2), nthcoeff(p, 3)
nthcoeff(poly(0, [x]), 1)
We demonstrate the evaluation strategy of nthcoeff:
p := poly(3*x^3 + 6*x^2*y^2 + 2, [x]): y := 4: nthcoeff(p, 2)
Evaluation is enforced by eval:
delete p, y:
A positive integer
Element of the coefficient domain of the polynomial. 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.