New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug in polynomial GCD computation #10996
Comments
Thanks for the valuable feedback! It looks like the algorithm for heuristic gcd is describeed on pages 320 ff. I can't see pages 327-330, however. Someone else will have to see if they can get the reference or some other way address the issue by finding the problem in the existing SymPy code.. |
@smichr No problem. I have an electronic copy of the book (legally obtained). Do you think I can extract the subsection describing the algorithm and send it to you? Not sure if it falls under any fair use clause. |
It seems that the version of heuristic gcd implemented in SymPy makes use of following upper bound for the roots In the code the test values have to be chosen strictly greater than twice the absolute values of the roots. Hence the choice should be modified:
|
Thanks for @jksuom, taken from sympy/sympy#10996 (comment) Closes sympy/sympy#10996
Thanks for @jksuom, taken from sympy/sympy#10996 (comment) Closes sympy/sympy#10996
This is incorrect:
The correct result is
-12*y**2*z-12*x**3*y**4+3*x*y**6
. This boils down to an error in the heuristic GCD. Indeed, the modular GCD works:The heuristic GCD does not:
I encountered the bug while implementing heuristic GCD in piranha (https://github.com/bluescarni/piranha). The test case above was generated randomly by fuzzy testing and it is the only one that fails. When I used sympy as a verification tool, sympy gave the same (wrong) result. It turns out that I used the same paper as sympy for the implementation of the heuristic GCD:
http://dl.acm.org/citation.cfm?id=220376
So at the very least it looks like in the paper the algorithm has been described in a way which leads to incorrect implementations. In piranha I ended up using the implementation of heuristic GCD as described in the book by Geddes:
https://books.google.de/books/about/Algorithms_for_Computer_Algebra.html?id=TXfY891RiiEC&redir_esc=y
This works so far in all test cases.
The text was updated successfully, but these errors were encountered: