# GroebnerBasis without specifying variables

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

GroebnerBasis[{poly1,poly2,...},{x1,x2,...}]


however it does return a result when ran just as

GroebnerBasis[{poly1,poly2,...}]


(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?

-

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 GroebnerBasisDistributedTermsList. 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};
Variables[polys]
Out[1]= {x, y, z}

GroebnerBasisDistributedTermsList[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}}

-
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. – process91 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. – process91 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
@process91 @DanielLichtblau Although this is way after the fact, I've had what I think was a similar problem, with a Module I wrote myself on Mma v9 for OS X, and then tried to run on my Mma v10 for RPi, which had a single input argument, but added the red caret as if it expected a second one. I haven't figured out the reason and can't run the code at this point. Might this be a version issue with Module between v9 and v10? – iwantmyphd Jan 29 at 5:11