5

I came across some weird behaviour when using GroebnerBasis. In m1 below, I used a Greek letter as my variable and in m2, I used a Latin letter. Both of them have no rules associated with them. Why do I get vastly different answers depending on what variable I choose?

Image:

enter image description here

Copyable code:

Clear["Global`*"]
g = Module[{x}, 
    x /. Solve[
      z - x (1 - b - 
           b x ( (a (3 - 2 a (1 + x)))/(1 - 3 a x + 2 a^2 x^2))) == 0,
       x]][[3]];
m1 = First@GroebnerBasis[\[Kappa] - g, z]
m2 = First@GroebnerBasis[k - g, z]

EDIT:

As pointed out by belisarius, my usage of GroebnerBasis is not entirely correct as it requires a polynomial input, whereas mine is not. This error, introduced by a copy-pasta, went unnoticed until now, as I was getting the answer that I expected when I followed through with the rest of my code using m1 from above. However, I'm not fully convinced that it is an unreasonable usage. Consider the example below:

x = (-b+Sqrt[b^2-4 a c])/2a;
p = First@GroebnerBasis[k - x,{a,b,c}]; (*get relation or cover for Riemann surface*)
q = First@GroebnerBasis[{D[p,k] == 0, p == 0},{a,b,c},k,
    MonomialOrder -> EliminationOrder]; 

Solve[q==0, b] (*get condition on b for double root or branch point*) 

{{b -> -2 Sqrt[a] Sqrt[c]}, {b -> 2 Sqrt[a] Sqrt[c]}}

which is correct. So my interpretation is that it is OK to use GroebnerBasis in such cases, but I'm not all too familiar with the deep theory behind it, so I could be completely wrong here.

P.S. I heard that if you mention GroebnerBasis three times in your post, Daniel Lichtblau will answer your question :)

Community
  • 1
  • 1
  • @yoda Sorry, deleted my previous comment. Are the solutions you get from Solve[ ] polynomials? – Dr. belisarius Jun 01 '11 at 05:17
  • @yoda I thought that `GroebnerBasis` works only for polys ... – Dr. belisarius Jun 01 '11 at 05:23
  • @yoda I have no idea, but I think you should edit your question with this info about usage – Dr. belisarius Jun 01 '11 at 05:38
  • @yoda Let's wait for Daniel ... :) – Dr. belisarius Jun 01 '11 at 06:10
  • It crashed my kernel twice. Something spooky going on there. – Sjoerd C. de Vries Jun 01 '11 at 08:35
  • 1
    I think there was a bug behind the crash with on ordering. Will be fixed. Not sure what will happen then (hang or new result). Difference between results, in absence of crash, probably due to internal variable ordering differences. If both results are correct, that is. Traveling right now, might get time to look more carefully next week. – Daniel Lichtblau Jun 04 '11 at 15:46
  • @Daniel: Thanks. The two results are not correct, only the first one is. Anyway, I'm not in a hurry so I'll wait till you have time. –  Jun 04 '11 at 17:08
  • @yoda Not much to report. Bug got fixed. Both now run longer than I was willing to wait. – Daniel Lichtblau Jun 23 '11 at 12:35
  • @Daniel: Oh, so will it be fixed in v9? The second runs for me in less than 30 secs. Anyway, please put that as an answer so that I can accept it. Also, while I still have v7, is there some way for me to know what variable(s) to choose to not trigger the bug? –  Jun 23 '11 at 13:25

2 Answers2

4

The bug that was shown by these examples will be fixed in version 9. Offhand I do not know how to evade it in versions 8 and prior. If I recall correctly it was caused by an intermediate numeric overflow in some code that was checking whether a symbolic polynomial coefficient might be zero.

For some purposes it might be suitable to specify more variables and possibly a non-default term order. Also clearing denominators can be helpful at least in cases where that is a valid thing to do. That said, I do not know if these tactics would help in this example.

I'll look some more at this code but probably not in the near future.

Daniel Lichtblau

Daniel Lichtblau
  • 6,854
  • 1
  • 23
  • 30
  • Thanks Daniel. This particular example doesn't matter, as I chose an example for which I knew the answer. – abcd Jun 23 '11 at 14:10
3

This may be related to the fact that Mathematica does not try all variable orders in functions like Simplify. Here is an example:

ClearAll[a, b, c]
expr = (c^4 b^2)/(c^4 b^2 + a^4 b^2 + c^2 a^2 (1 - 2 b^2));
Simplify[expr]
Simplify[expr /. {a -> b, b -> a}]
   (b^2 c^4)/(a^4 b^2 + a^2 (1 - 2 b^2) c^2 + b^2 c^4)
   (a^2 c^4)/(b^2 c^2 + a^2 (b^2 - c^2)^2)

Adam Strzebonski explained that:

...one can try FullSimplify with all possible orderings of chosen variables. Of course, this multiplies the computation time by Factorial[Length[variables]]...

Mr.Wizard
  • 24,179
  • 5
  • 44
  • 125