On Tue, Sep 18, 2012 at 4:14 PM, Oscar <[email protected]> wrote:
> 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

Oh, that's good to hear.  Nonetheless, the issue I noted can happen,
because Poly doesn't ever check for algebraic relations on the
generators, even trivial ones (like sqrt(5)**2 == 5).

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

It shouldn't take more than ten minutes or so.  Is there some test
that is hanging?

Most people honestly run only those parts of the test suite that they
know might be affect (so e.g., if you change something in the stats
module, then you only need to run the stats tests). But that's only if
you have a good idea of what might or might not be affected by your
change.  And anyway, for the polys, all of SymPy uses it, so you
really do have to run the whole tests to see.

Aaron Meurer

>
> 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.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
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.

Reply via email to