# Polynomial Orderings

The leading term of a polynomial can be chosen in many different ways. For multivariate polynomials, sorting by the total degree of the monomials is often useful.

Different representations of polynomials.

Here is a polynomial in three variables.

Out[1]= | |

This is the list of the monomials.

Out[2]= | |

This is the list of the monomials represented as exponent vectors and coefficients.

Out[3]= | |

The first vector corresponds to

.

Out[4]= | |

Out[5]= | |

If the second argument to

MonomialList or

CoefficientRules is omitted, the variables are taken in the order in which they are returned by the function

Variables.

The list of the variables is not always sorted.

Out[6]= | |

Now the first vector corresponds to

.

Out[7]= | |

Out[8]= | |

By default, the monomials are sorted lexicographically and given in the decreasing order. In the previous example,

(corresponding to

) is taken to precede

(corresponding to

) by the second element.

An order is described by defining how two vectors of exponents

and

are sorted. For the lexicographic order,

.

An order can also be described by giving a weight matrix. In that case the exponent vectors are multiplied by the weight matrix and the results are sorted lexicographically, also in the decreasing order. The matrices for different orderings are given as follows.

Weight matrices corresponding to different orderings.

For functions such as

GroebnerBasis and

PolynomialReduce, it is necessary that the order be well-founded, which ensures that any decreasing sequence of elements is finite (the elements being the vectors of non-negative exponents). In order for that condition to hold, the first nonzero value in each column of the weight matrix must be positive.

The default sorting used for polynomial terms in an expression corresponds to the negative lexicographic ordering with variables sorted in the reversed order. This is commonly known as reverse lexicographic ordering.

This is the internal representation of a polynomial. The arguments of

Plus and

Times are sorted on evaluation.

Out[9]//FullForm= |

| |

This is the sorted list of terms.

Out[10]= | |

This is the reverse lexicographic order in variables

.

Out[11]= | |

This is the same order specified by a weight matrix.

Out[12]= | |

The result is identical to the automatically sorted list of terms in

poly.

Out[13]= | |

TraditionalForm tries to arrange the terms in an order close to the lexicographic ordering.

Out[14]//TraditionalForm= |

| |

This uses advanced typesetting capabilities to obtain the list of terms in the same order as they appear in the

TraditionalForm output.

Out[15]= | |

The result agrees with the list of the monomials given in the default (lexicographic) order.

Out[16]= | |

The option

tells

TraditionalForm which variables should be excluded from the ordering.

By default, the list of independent variables is assumed to be

.

Out[17]//TraditionalForm= |

| |

Here

x is assumed to be the only variable.

Out[18]//TraditionalForm= |

| |

One can obtain additional orderings from the six orderings used in

MonomialList simply by reversing the resulting list. This is effectively equivalent to negating the exponent vectors. In a commutative setting, one can also obtain other orderings by reversing the order of the variables.

This diagram illustrates the relations between various orderings. Red lines indicate reversing the list of variables and blue lines indicate negating the power vectors.