-
-
Notifications
You must be signed in to change notification settings - Fork 648
Fixed infinite recursion in trig functions #40020
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
Conversation
Documentation preview for this PR (built with commit 49e3393; changes) is ready! 🎉 |
Thanks for doing this. It looks good, but in pynac you should use |
Local doctesting did not show any unexpected errors. |
sagemathgh-40020: Fixed infinite recursion in trig functions <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> Fixes sagemath#35696 When the trig functions sin, cos, tan, csc, sec, or cot are provided with a symbolic input which expands to 0 they would suffer an infinite recursion error. This occurred because of a bug in the corresponding sin_eval, cos_eval, tan_eval, csc_eval, sec_eval, and cot_eval functions defined in src/sage/symbolic/ginac/inifcns_trig.cpp. These functions perform a simplification when the real part of the expanded input is 0. This simplification led to infinite recursion when the expanded input was exactly equal to 0. A check has been added to each of these 6 functions which ensures correct behaviour when the input expands to 0. Tests have been added to src/sage/functions/trig.py to cover these changes. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [X] The title is concise and informative. - [X] The description explains in detail what this PR is about. - [X] I have linked a relevant issue or discussion. - [X] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#40020 Reported by: Caleb Van't Land Reviewer(s):
Fixes #35696
When the trig functions sin, cos, tan, csc, sec, or cot are provided with a symbolic input which expands to 0 they would suffer an infinite recursion error.
This occurred because of a bug in the corresponding sin_eval, cos_eval, tan_eval, csc_eval, sec_eval, and cot_eval functions defined in src/sage/symbolic/ginac/inifcns_trig.cpp. These functions perform a simplification when the real part of the expanded input is 0. This simplification led to infinite recursion when the expanded input was exactly equal to 0.
A check has been added to each of these 6 functions which ensures correct behaviour when the input expands to 0.
Tests have been added to src/sage/functions/trig.py to cover these changes.
📝 Checklist
⌛ Dependencies