Created
January 15, 2011 05:20
-
-
Save acdimalev/780718 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define pi 3.1415926535897932 | |
double sin(double a) { | |
double y; | |
double x = a / (pi / 2); | |
int fol = x; | |
int neg = (int)(x / 2) & 1; | |
int inv = (int)x & 1; | |
x = x - fol; // fold | |
x = (1 - inv) * x + inv * (1 - x); // invert? | |
a = x * (pi / 2); | |
y = a * (1 - a*a/6 * (1 - a*a/20 * (1 - a*a/42 * (1 - a*a/72 * | |
(1 - a*a/110 * (1 - a*a/156 * (1 - a*a/210 * (1 - a*a/272 * | |
(1 - a*a/342 * (1 - a*a/420)))))))))); | |
y = neg * -y + (1 - neg) * y; // negate? | |
return y; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment