c programming: computing sine using triple-angle formula
![]()
* image taken from list of trigonometric identities at Wikipedia. * simplify above equation to make our life easier, we get![]()
from above equation we can now solve sin(x).
here's a simple solution using recursive loop until angle reach zero value
-
double cube (double x) {
-
return x*x*x;
-
}
-
double sine (double angle) {
-
if (angle < 0.00000001) { return angle; }
-
return 3*(sine (angle/3.0)) - 4*cube(sine (angle/3.0));
-
}
-
int main() {
-
return 0;
-
}
-
the output is: 0.826880
No Comments Yet