I want to test some silly ideas about just swapping out sin(pi*x), but first we gotta know how to bench em. https://github.com/martinus/nanobench seems good.
(as to "what ideas": the pi multiplication offers very cheap range reduction for us. after that we're probably free to use Bhāskara and other cheap-ass stuff.
// what are you gonna do about it? x can't be too big!
inline double red4(double x){
return fma(-round(x * 0.25), 4, x);
}
inline double sinpi_nick(double x) {
x = red4(x * 2); // = 0 to 2pi; nick-magic works on units of 0.5pi
double y = x * (2 - abs(x));
return y * (0.775 + 0.225 * abs(y));
}
I want to test some silly ideas about just swapping out sin(pi*x), but first we gotta know how to bench em. https://github.com/martinus/nanobench seems good.
(as to "what ideas": the pi multiplication offers very cheap range reduction for us. after that we're probably free to use Bhāskara and other cheap-ass stuff.