# Lex -- lexicographical monomial order.

## Description

The lexicographic order is defined by: xA > xB if the FIRST non-zero entry of the vector of integers A-B is POSITIVE.
 `i1 : R = QQ[a..d, MonomialOrder => Lex];` ```i2 : a^3 + a^2*b^2 + b*c 3 2 2 o2 = a + a b + b*c o2 : R```
The largest possible exponent of variables in Lex order is 2^31-1. For efficiency reasons, the size of the exponents of variables may be restricted. Then instead of Lex, one can use MonomialSize=>16, which allows maximal exponent 2^15-1, or MonomialSize=>8, which allows maximal exponent 2^7-1.
 `i3 : B = QQ[a..d,MonomialOrder=>Lex,MonomialSize=>16];` ```i4 : a^(2^15-1) 32767 o4 = a o4 : B``` `i5 : C = QQ[a..d,MonomialOrder=>Lex,MonomialSize=>8];` ```i6 : try a^(2^15-1) else "failed" o6 = failed``` ```i7 : a^(2^7-1) 127 o7 = a o7 : C```
Any of these versions of Lex order may be combined, for example, with a weight order given by a weight vector: x^A > x^B if weight(x^A) > weight(x^B) or if weight(x^A) = weight(x^B) and if the FIRST non-zero entry of the vector of integers A-B is POSITIVE.
 `i8 : B = QQ[a..d,MonomialSize=>16,MonomialOrder=>{Weights => {1,2,3,4}, Lex}];` ```i9 : a^2 + b+ c + b*d 2 o9 = b*d + c + a + b o9 : B```