4 ms·
I tried to write a library to calculate vectorized trig functions. Minimax or least-squares polynomials are much much better than Taylor series. But here's th
by jeremysalwen 15y ago
I tried to write a library to calculate vectorized trig functions. Minimax or least-squares polynomials are much much better than Taylor series. But here's the thing: The majority of the computation required is not in the calculation of the kernel (i.e. f(x) for -pi/2<x<pi/2) but getting accurate reduction to this range for all possible floating point values. If you're using single precision numbers, you really only need the first 9 terms of the minimax polynomial (=x+x^3+x^5+x^7+x^9) to get within two ulps of accuracy. But doing extremely precise division of large numbers is not so quick.
If you're interested, I have the test code here: https://github.com/jeremysalwen/vectrig https://github.com/jeremysalwen/vectrig