Every polynomial ring in Macaulay2 comes equipped with an ordering on the monomials.Polynomials are displayed by ordering the monomials in decreasing order. The choice of monomial order can make a difference in the time and space required for various computations, especially Gröbner basis computations.See below for the definitions of all implemented orderings.
The default ordering is
GRevLex, the graded reverse lexicographic order.This means that terms of higher total degree come first; and for two terms of the same degree, the term with the higher power of the last variable comes last; for terms with the same power of the last variable, the exponent on the next to last variable is consulted, and so on.
i1 : R=ZZ/101[a,b,c]
o1 = R
o1 : PolynomialRing
|
i2 : (a+b+c+1)^2
2 2 2
o2 = a + 2a*b + b + 2a*c + 2b*c + c + 2a + 2b + 2c + 1
o2 : R
|
Explicit comparison of monomials with respect to the chosen ordering is possible.
The comparison operator
? returns a symbol indicating the result of the comparison: the convention is that the larger monomials are printed first (leftmost).
i4 : b^2 ? a*c
o4 = >
o4 : Keyword
|
The monomial ordering is also used when sorting lists with
sort.
i5 : sort {1_R, a, a^2, b, b^2, a*b, a^3, b^3}
2 2 3 3
o5 = {1, b, a, b , a*b, a , b , a }
o5 : List
|
The next ring uses graded lexicographic ordering. This means that terms of higher total degree come first; for two terms of the same degree, the term with the higher power of the first variable comes first: for terms with the same power of the first variable the power of the second variable is consulted, and so on.
i6 : R=ZZ/101[a,b,c,MonomialOrder=>GLex];
|
i7 : (a+b+c+1)^2
2 2 2
o7 = a + 2a*b + 2a*c + b + 2b*c + c + 2a + 2b + 2c + 1
o7 : R
|
(Notice how similar the result above is to the one obtained when graded reverse lexicographic ordering is used.)
The next ring uses lexicographic ordering. This means that terms with the highest power of the first variable come first: for two terms with the same power of the first variable the power of the second variable is consulted, and so on.
i8 : R=ZZ/101[a,b,c,MonomialOrder=>Lex];
|
i9 : (a+b+c+1)^2
2 2 2
o9 = a + 2a*b + 2a*c + 2a + b + 2b*c + 2b + c + 2c + 1
o9 : R
|
The next ring uses an elimination order suitable for eliminating the first two variables,
a and
b. In such an ordering we want all terms in which either of the first two variables appears to come before all of those terms in which the first two variables don't appear. This particular ordering accomplishes this by consulting first the total degree of the first two variables, and in case of a tie, consulting the graded reverse lexicographic ordering of the entire monomials.
i10 : R=ZZ/101[a,b,c,MonomialOrder=>Eliminate 2];
|
i11 : (a+b+c+1)^2
2 2 2
o11 = a + 2a*b + b + 2a*c + 2b*c + 2a + 2b + c + 2c + 1
o11 : R
|
The next ring uses the product ordering that segregates the first variable from the next two. This means that terms come first that would come first in the graded reverse lexicographic ordering when their parts involving the second two variables are ignored, and in case of equality, the graded reverse lexicographic ordering of their parts involving just the next two variables is consulted.
i12 : R=ZZ/101[a,b,c,MonomialOrder=>ProductOrder{1,2}];
|
i13 : (a+b+c+1)^2
2 2 2
o13 = a + 2a*b + 2a*c + 2a + b + 2b*c + c + 2b + 2c + 1
o13 : R
|