Anyway, I've got a task that requires a lot of use sine and cosine, and I've decided that speed in computation is far more important than accuracy, as there is a very small number of digits that are significant. So the solution that I came up with is to make a method that uses a polynomial approximation instead. Something like 'check for domain and subtract pi until in domain' then apply the polynomial. Would this compute faster or slower than the built in trig functions? Is there an easy way to test this?
>>2
You were right, a 1 million operation loop showed that the built in function was much, much faster than what I had in mind; I guess the difference is that the polynomials and all their operations each have to be processed by ruby, where the cos operation only has to be dealt with once.
Not sure about using a table though, might be worth checking.