There are also some libraries that provide vectorized implementations, often with a few options for different accuracy/performance tradeoffs.
test fast_sine ... bench: 746,638 ns/iter (+/- 2,489)
test normal_sine ... bench: 1,535,147 ns/iter (+/- 13,731) test fast_sine ... bench: 6 ns/iter (+/- 0)
test normal_sine ... bench: 13 ns/iter (+/- 0)If you can do [0,pi], a few operations give you the entire domain, no?
In my day job doing motor control, I track shaft angle using a 16 bit fixed-point integer. It wraps around perfectly and I've got an awesome sin(x) function that takes -32768 to 32767 as input (equivalent to -pi to +pi) and returns a fixed point value in a few operations.
It's all a matter of using a representation that make whatever you're doing easy to compute.
If you really must work in terms of angle measures, use “binary degrees” https://en.wikipedia.org/wiki/Binary_scaling#Binary_angles