Take the 2-minute tour ×

All the examples in the Mathematica documentation specify that the syntax for the GroebnerBasis command is


however it does return a result when ran just as


(although it does put a red caret in at the end, indicating it is missing an expected second parameter). I assume that, in this case, GroebnerBasis makes some choice for the variables. My intuition was that it would be GroebnerBasis[polys] == GroebnerBasis[polys, Variables[polys]], but that does not seem to be the case. What is the behavior of the GroebnerBasis command without a variable specification?

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

If the (ordered) list of veriables is not specified, GroebnerBasis will order the variables as it encounters them. I remark that, as this depends on implementation details, it can be version dependent.

The question (which I should have anticipated) was raised as to how one might get the "variables" that GroebnerBasis sees, and in the same order. It can be done with a non-System-context function GroebnerBasis`DistributedTermsList. It will both rewrite the polynomials in an internal format (as its name implies), and also give the variables in the order it is using them. One must specify CoefficientDomain->Rationals in order to force it to create new variables rather than treat unspecified ones as part of the coefficient field (the default behavior).

Here is a simple example.

polys = {3*y*z - 5, 2*x^2 + y + z^3 - 1, x*y - 2};
Out[1]= {x, y, z}

GroebnerBasis`DistributedTermsList[polys, CoefficientDomain -> Rationals]
Out[2]= {{{{{1, 1, 0}, 3}, {{0, 0, 0}, -5}}, {{{1, 0, 0}, 1}, {{0, 3, 0}, 1}, 
    {{0, 0, 2}, 2}, {{0, 0, 0}, -1}}, {{{1, 0, 1},1}, {{0, 0, 0}, -2}}}, {y, z, x}}
share|improve this answer
Any way to get a list of the variables ordered in this way? I think the "Variables[polys]" command reorders them on it's own. –  Michael Boratko Mar 13 '12 at 19:13
@Michael See edit. –  Daniel Lichtblau Mar 13 '12 at 20:17
Thank you, your expertise has been extremely valuable to me. I hope Wolfram pays you well. –  Michael Boratko Mar 13 '12 at 20:33
No, but they nowadays let me turn off the lights at night; 24 hours of fluorescence was really starting to make me feral. Brett says I should also mention the tip jar... –  Daniel Lichtblau Mar 13 '12 at 20:48
add comment

Your Answer


