In what order should the terms of a polynomial in several variables be written

abstract-algebraconventionnotationpolynomialsring-theory

Given a polynomial in one indeterminate, it is standard to write it in the form $a_0+a_1x+a_2x^2+\dots +a_nx^n$ (increasing order of degree) or $a_nx^n+a_{n-1}x^{n-1}+\dots+a_0$ (decreasing order of degree).

Is there a similar convention for how you should write a polynomial in several indeterminates $x_1,\dots,x_n$? (I would also be interested in the case of infinitely many indeterminates, though perhaps there isn't so much of a settled convention in this situation.)

Best Answer

The case of $n$ indeterminates corresponds to the orderings of length-$n$ strings of nonnegative integers (which are the exponents of the variables in the monomials). The case of infinitely many indeterminates corresponds to the orderings of infinite strings of nonnegative integers such that only finitely many are nonzero. There are many ways to choose ordering: lexicographic, reverse lexicographic, colexicographic, degree (or, graded) colexicographic, etc.

Computer algebra systems generally have to solve the more general latter problem, as they need to handle polynomials in any variables. In particular, Mathematica claims that it sorts terms in the reverse lexicographic ordering of exponents, but I think it is actually colexicographic:

  • first, group the terms according to the greatest index of the variable and sort the groups in the increasing order, e.g. all terms with $x_2$ but no $x_i$ with $i>2$ go before all terms with $x_3$;
  • within each group, group and sort in the increasing order according to the exponent of that variable;
  • within each subgroup, repeat recursively (ignoring the common factor processed on previous steps).

For the case of $n$ indeterminates, one can implement that sorting by writing down the vectors of exponents and comparing the reversed vectors in the lexicographic order: e.g., for $n=4$, the terms $x_1x_2^2x_3^3$ and $x_1^3x_2x_3^3$ have exponent vectors $(1,2,3,0)$ and $(3,1,3,0)$, after reversing they become $(0,3,2,1)$ and $(0,3,1,3)$, the latter vector goes first lexicographically, so the latter monomial goes first.

Sage uses what can be called degree-decreasing colexicographic order: first, group and sort terms in the decreasing order according to the degree of the monomial, and then within each group apply the Mathematica ordering.

Other CASs or authoritative sources can have different conventions.

Some descriptions of orderings are given in Wikipedia or in the OEIS Wiki.

Related Question