On Tuesday, 18 September 2012 19:09:57 UTC+1, Aaron Meurer wrote: > This is indeed a bug! > > The problem appears to be in cancel(). It creates two polynomials, > Poly(1317378933230047068160*sqrt(5) + 2945748836994210856960, sqrt(5), > domain='ZZ') Poly(120352542776360960*sqrt(5) + 269116466014453760, > sqrt(5), domain='ZZ'), and applies Euclid's algorithm on them to find > the gcd, and then polynomial division. The problem is that the > generator sqrt(5) is an algebraic, so certain polynomials in it will > be identically zero. But Poly does not know this, so somewhere in gcd > or div it comes across such a polynomial and assumes that it is not > zero, leading to the incorrect result. If you want, you may try > applying the algorithm by hand as an exercise to see where it goes > awry. You might even be able to figure out why 21 is the magic number > where it starts to go bad. > > If you use expand() and then radsimp(), you get the correct result. > > The only way to really fix this would be to prevent cancel, and really > Poly in general, from creating generators from algebraic numbers. > This would unfortunately break a lot of things that otherwise work > just fine (because they never come across these identically zero > polynomials in the generators). >
It turns out to be a lot simpler than that. There was a typo in the return value from dup_zz_heu_gcd() in the euclidtools module. I've sent a pull request here: https://github.com/sympy/sympy/pull/1533 I've no idea why it only occurs for all fibonacci numbers above the 20th as I don't fully understand the heuristic algorithm. I'm pretty confident about the typo though. Also, it takes a really long time to run the test suite on my computer (I went to the shop and it was still going when I got back). Do people really run that every time before committing? Oscar -- You received this message because you are subscribed to the Google Groups "sympy" group. To view this discussion on the web visit https://groups.google.com/d/msg/sympy/-/lR06pZXnXJYJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
