|
|
|
|
|
by drej
1759 days ago
|
|
Nice. Reminds me of an optimisation trick from a while ago: I remember being bottlenecked by one of these trigonometric functions years ago when working with a probabilistic data structure... then I figured the input domain was pretty small (a couple dozen values), so I precomputed those and used an array lookup instead. A huge win in terms of perf, obviously only applicable in these extreme cases. |
|
If abs(x) < 0.1, "sin(x)" is approximated really well by "x".
That's it. For small x, just return x.
(Obviously, there is some error involved, but for the speedup gained, it's a very good compromise)