Documentation |
Sorted list of monomials of a polynomial
This functionality does not run in MATLAB.
monomials(p, <order>) monomials(f, <vars>, <order>)
monomials(p, order) returns the list of non-zero monomials of the polynomial p. The list is sorted with respect to the term ordering order.
monomials returns a list of all non-trivial monomials of the polynomial given. The monomials are sorted according to the term ordering given. The list is empty if the polynomial is zero.
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 list of polynomial expressions. FAIL is returned if f cannot be converted to a polynomial.
The result of monomials is not fully evaluated. It can be evaluated by the functions mapcoeffs and eval. Cf. Example 4.
We give some self explaining examples:
p := poly(100*x^100 + 49*x^49 + 7*x^7, [x]): monomials(p)
monomials(poly(0, [x]))
delete p:
We demonstrate the effect of various term orders:
p := poly(5*x^4 + 4*x^3*y*z^2 + 3*x^2*y^3*z + 2, [x, y, z]): monomials(p)
monomials(p, DegreeOrder)
monomials(p, DegInvLexOrder)
delete p:
This example features a user defined term ordering. Here we use the reverse lexicographical order on 3 indeterminates:
order := Dom::MonomOrdering(RevLex(3)): p := poly(5*x^4 + 4*x^3*y*z^2 + 3*x^2*y^3*z + 2, [x, y, z]): monomials(p, order)
delete order, p:
We demonstrate the evaluation strategy of monomials:
p := poly(3*x^3 + 6*x^2*y^2 + 2, [x]): y := 4: monomials(p)
Evaluation is enforced by eval:
map(%, mapcoeffs, eval)
delete p, y:
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: LexOrder, or DegreeOrder, or DegInvLexOrder, or a user-defined term ordering of type Dom::MonomOrdering. The default is the lexicographical ordering LexOrder. |