# monomial orders for free modules

In Macaulay2, each free module F = Rs over a ring R has a basis of unit column vectors F0, F1, ..., F(s-1). The monomials of F are the elements m Fi, where m is a monomial of the ring R. In Macaulay2, orders on the monomials of F are used for computing Gröbner bases and syzygies, and also to determine the initial, or lead term of elements of F.

The ring R comes equipped with a total order on the monomials of R. A total order on the monomials of F is called compatible (with the order on R), if m Fi > n Fi (in F) whenever m > n (in R). There are many types of compatible orders, but several stand out: term over position up (the default in Macaulay2), term over position down, position up over term, position down over term, and Schreyer orders.

term over position up: m Fi > n Fj iff m>n or m==n and i>j

term over position down: m Fi > n Fj iff m>n or m==n and i<j

position up over term: m Fi > n Fj iff i>j or i==j and m>n

position down over term: m Fi > n Fj iff i<j or i==j and m>n

Induced monomial orders are another class of important orders on F, see Schreyer orders for their definition and use in Macaulay2.

In Macaulay2, free modules come equipped with a compatible order. The default order is: term over position up. This is called Position=>Up. In the following example, the lead term is a F1, since a > b.

 `i1 : R = ZZ[a..d];` ```i2 : F = R^3 3 o2 = R o2 : R-module, free``` ```i3 : f = b*F_0 + a*F_1 o3 = | b | | a | | 0 | 3 o3 : R``` ```i4 : leadTerm f o4 = | 0 | | a | | 0 | 3 o4 : R```
This is the same as giving the monomial order as:
 `i5 : R = ZZ[a..d, MonomialOrder => {GRevLex => 4, Position => Up}];` ```i6 : F = R^3 3 o6 = R o6 : R-module, free``` ```i7 : leadTerm(a*F_0 + a*F_1) o7 = | 0 | | a | | 0 | 3 o7 : R```
Giving Position=>Down instead switches the test above to i < j. In this case the monomial order on F is: m*F_i > n*F_j if m>n or m==n and i<j.
 `i8 : R = ZZ[a..d, MonomialOrder => {GRevLex => 4, Position => Down}];` ```i9 : F = R^3 3 o9 = R o9 : R-module, free``` ```i10 : leadTerm(a*F_0 + a*F_1) o10 = | a | | 0 | | 0 | 3 o10 : R```
If one gives Position=>Up or Position=>Down earlier, then the position will be taken into account earlier. For example
 `i11 : R = ZZ[a..d, MonomialOrder => {GRevLex => 2, Position => Down, GRevLex => 2}];` ```i12 : F = R^3 3 o12 = R o12 : R-module, free``` ```i13 : leadTerm(a*F_0 + a*F_1) o13 = | a | | 0 | | 0 | 3 o13 : R``` ```i14 : leadTerm(b*F_0 + c^4*F_1) o14 = | b | | 0 | | 0 | 3 o14 : R``` ```i15 : leadTerm(c*F_0 + d^2*F_1) o15 = | c | | 0 | | 0 | 3 o15 : R```
If one wants Position over Term (POT), place the Position element first
 `i16 : R = ZZ[a..d, MonomialOrder => {Position => Down}];` ```i17 : F = R^3 3 o17 = R o17 : R-module, free``` ```i18 : leadTerm(a*F_0 + a*F_1) o18 = | a | | 0 | | 0 | 3 o18 : R``` ```i19 : leadTerm(b*F_0 + c^4*F_1) o19 = | b | | 0 | | 0 | 3 o19 : R``` ```i20 : leadTerm(c*F_0 + d^2*F_1) o20 = | c | | 0 | | 0 | 3 o20 : R```