Archived

This topic is now archived and is closed to further replies.

DevLiquidKnight

Making a faster cosf, and sinf function?

Recommended Posts

quote:
Original post by Foxostro
Try using look up tables. Personally, I like to use arrays with 3600 values or so and precompute the values.


Sizing your table to be a power of two makes better sense. Remember that dividing a circle in ''360 degrees'' is a completely arbitrary decision.


“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”
— Brian W. Kernighan (C programming language co-inventor)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Also, if you weren''t exactly going for accuracy, you could always break it down into the Taylor Polynomials around whichever point was closest to you.... for some points (pi/3, for example) a linear approximation does wonders.

Share this post


Link to post
Share on other sites
quote:
Original post by Foxostro
Try using look up tables. Personally, I like to use arrays with 3600 values or so and precompute the values.


Way to kill the cache. A 14K lookup table sounds like a bad idea to me... Anyway I would recommend the taylor-series approimations (you can find them everywhere). To seven powers should give you accuracy in the range [0, 2 * pi) that is good enough for government work.

Share this post


Link to post
Share on other sites