-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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: scipy.special.sindg returns 0.0 for large argument #20723
Comments
It seems the limit |
I believe this error is only shown if you enable the error: scipy.special.seterr(no_result='raise') Results in:
I'm not sure there's an accurate way to do this for large x. If x is large, then x is not very precise in an absolute sense. If x is about 1e14, then x % 360 can be accurate, at most, to 5 decimal digits of precision. I agree that the current state of things is not great, though. At minimum, this ought to be documented. |
Thanks for the comments @nickodell. The With some googling, I find this StackOverflow thread that elaborates the issues with large argument, and this pdf that explains range reduction when the argument is in radian. My take away is that when the argument is very large, the result is almost certainly useless for the practical problem because a tiny relative error in the argument can lead to completely different result. So the best practice is never to work with huge angles. On the other hand, if the huge angle is against all odds exact, then it would be ideal to return a correct result for |
Describe your issue.
scipy.special.sindg(x)
computes the sine ofx
wherex
is measured in degree. It returns0.0
whenx > 1e14
.From the source code it appears this behavior is expected. However, when I use Jupyter Notebook I didn’t get an error or warning message and the function “silently” returned zero.
Though the large argument is probably not so commonly used in practice, it may still be desirable to support it if possible. (One possibility is to provide a function that converts degree to radian and reduce it into
[-pi,pi]
in one step.)Reproducing Code Example
Error message
SciPy/NumPy/Python version and system information
SciPy 1.12 / Python 3.10 / Windows, though I think the issue is platform independent and also exists in HEAD.
The text was updated successfully, but these errors were encountered: