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
log of NaN in RealField and ComplexField results in infinite loop #15388
Comments
comment:3
A couple things
|
Reviewer: Ben Hutz |
comment:5
long doctest looks fine with this, so I'm happy with the code change, just make the minor changes suggested above. Just to note, I had a few unrelated longtest failures on 5.12 that failed both with and without the patch.
|
comment:7
It is probably best not to have an example involving NaN in the log's documentation, as it is such a basic function and this case is rather exceptional. (Although we still want it to work in case a log appears in someone's code after an NaN has already appeared, as happened to us when we found this bug.) |
comment:8
We have made the changes Ben suggested, except for adding a doctest, which seems undesirable as noted above. |
comment:10
This looks good. |
Work Issues: doctest |
comment:11
Replying to @pfili:
Which is exactly why a doctest is needed. |
comment:12
I have added a doctest that explains the behavior for NaN. |
comment:13
Ok. This still looks fine and now we have the doctests. |
comment:14
You should add a meaningful commit message (use |
Changed work issues from doctest to none |
Fixes the behavior of log(NaN) in real and complex fields |
comment:15
Attachment: trac_15388_nan_fix.patch.gz Commit message has been added. |
comment:16
ok. still looks good, but with a commit message this time. |
Merged: sage-5.13.beta3 |
Changed reviewer from Ben Hutz to Benjamin Hutz |
If you have a RealField or ComplexField NaN value and attempt to compute log, the fact that NaN is considered < 0 results in RealField.log calling ComplexField.log, but then ComplexField.log calls RealField.log again, but again on the values NaN for the absolute value. This results in an infinite loop. Example code for the code:
x = RealField()(NaN)
x.log() # Results in infinite loop
This patch fixes the log function in RealField and ComplexField to return NaN if fed a number which is NaN (in either the real or the imaginary coordinate).
CC: @sagetrac-atowsley
Component: numerical
Keywords: sage-days55
Author: Paul Fili, Adam Towsley
Reviewer: Benjamin Hutz
Merged: sage-5.13.beta3
Issue created by migration from https://trac.sagemath.org/ticket/15388
The text was updated successfully, but these errors were encountered: