-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
cosc(x::Float64) is implemented using a Taylor polynomial approximation around x = 0, and a generic formula relying on sinpi(x::Float64) and cospi(x::Float64) for the general case.
The polynomial approximation around the zero at x = 0 is necessary because the generic formula for cosc has bad accuracy around the zeros of cosc. However, the transition between the two implementation pieces is awkward, see the error plot (after downsampling by taking the max error) of the approximation error in ULPs:
The transition between the two implementation happens at 0.14, so the error is a bit high on both sides of the transition. It might make sense to lower it to like 5 ULPs or less, instead of the current 30 ULPs.
Two possible improvements:
-
Using a Taylor polynomial is suboptimal, a minimax polynomial (odd, like the Taylor series) should be more efficient.
-
If necessary, it might make sense to introduce an additional minimax polynomial to transition between the first approximation polynomial and the generic formula-based implementation.