Trying to implement a sine function that uses the series:
sin(x) = x - x^3/3! + x^5/5! - x^7/7! + ...
, but it only returns 0.0000. I'm obviously doing it wrong. Any suggestions?
Code:double sine(float angle){ int y; double radians; radians = angle * (M_PI / 180.0); if(radians > 0.0){ for(y = 1; !((fabs(pow(radians, y))/fact(y)) - (pow(radians, y+2)/fact(y+2)) < EPSILON); y = y + 2);//empty body } return ((pow(radians, y))/fact(y)); }