Bonfra wrote:
sin, cos
It's a lot easier to come up with good approximations for sin() and cos() if you can ensure the argument will always be within a small range, such as (-π/4,π/4).
Here's a paper about argument reduction. It's possible to implement this argument reduction using only integer operations, which I think is easier than using floating point operations.
If the reduced argument is sufficiently small, sin() returns the reduced argument, and cos() returns 1. With that, you can further reduce the range over which your approximations need to be accurate, although you may find this step to be unnecessary.
Note that the argument reduction algorithm presented in the paper I linked above includes
r =
f·(
π/2) for the final step of computing the reduced argument. You'll get some odd results if you forget that step!
Unfortunately, that's as far as I've gotten - I don't have any good approximations for sine or cosine after the argument is appropriately reduced.