-
-
Notifications
You must be signed in to change notification settings - Fork 5.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
add sinpi cospi functions #4112
Conversation
+1 (In FFTW, we had to implement something much like this, albeit only for rational arguments.) |
Ah, I didn't think of rationals: I'll just tweak it a bit for those. |
Unfortunately I can't get |
I'm quite sympathetic to having the correct expensive versions of these sorts of things and working hard to make sure we can get them as fast as possible. In general there tends to be an obvious imperfect but close and fast version – e.g. just using |
The range reduction for The rest is tricky, because not only do we have the rounding of the multiplication, we also have the rounding of julia> sin(pi/6)
0.49999999999999994
julia> float64(sin(big(pi)/6))
0.5
julia> sin(float64(big(pi)/6))
0.5 Yet if we round julia> sin(pi*(1/6))
0.49999999999999994
julia> float64(sin(big(pi)*(1/6)))
0.5
julia> sin(float64(big(pi)*(1/6)))
0.49999999999999994 |
Well, just let me know and I'll merge this if you feel it's ready. |
I'm happy with it as it stands, but others may have opinions as to whether it's worth inserting a clause to handle the The only other thing that could be worth thinking about is defining |
Ok, merging. |
add sinpi cospi functions
Can we please stop merging patches that don't update the documentation as needed? It would be good to institute this as a general rule. |
Yes, that's a fair point. @simonbyrne, would you please make another PR with docs? |
Adds functions for accurately computing
sin(pi*x)
andcos(pi*x)
using range reduction: the main benefit is thatsinpi(0.5) == 1.0
andsinpi(1.0) == 0.0
. Used internally insinc
function and several other places.