-
-
Notifications
You must be signed in to change notification settings - Fork 649
Description
Is there an existing issue for this?
- I have searched the existing issues for a bug report that matches the one I want to file, without success.
Did you read the documentation and troubleshoot guide?
- I have read the documentation and troubleshoot guide
Environment
- **OS**: MacOS 11, Ubuntu 22.04, others
- **Sage Version**: 9.1, 9.8, 10.0, others
Steps To Reproduce
Enter sin( x*(x+1) - x^2 - x )
at the sage prompt.
Expected Behavior
Sage should return "sin( x*(x+1) - x^2 - x )" (or return "0").
Actual Behavior
Sage hangs, and eventually crashes because it runs out of memory.
Additional Information
This is a simplified example of the bug reported by Daniel Bump in this sage-devel thread (and analyzed by Nils Bruin). The same problem also shows up when sin
is replaced with cos
or tan
.
The bug for sine is in the sin_eval
and sinh_eval
methods in pynac's inifcns_trig.cpp and inifcns_hyperb.cpp files. The method sin_eval
determines that the argument is a multiple of I
(because xred.expand()
is numeric and is equal to 0
, and is therefore a multiple of I
), so the method "simplifies" the expression to I*sinh(xred/I)
. However, the argument of sinh
in this expression is a multiple of I
, so the sinh_eval
method decides to evaluate sin
. This is an infinite loop.
I think the bug could be fixed by returning 0
if xred.expand()
is 0
(and making a similar correction for other trig functions and hyperbolic trig functions).