chrisdew chrisdew - 15 days ago 6
C Question

Simple approximation of Sine

I'm looking for an approximation for Sine which is correct at

x == 0
and
x == 90
or
x == pi/2
and within 5% otherwise.

I have no space for look-up tables.

Answer

You seem to be able to use Bhaskara I's sine approximation formula :

float x;
float sinx = 4 * x * (180 - x) / (40500 - x * (180 - x));

The error stays within 2%.

Very fast and can be optimized (by hand).