hello,
i have a small project which ask the user to input value of 'x', then show sin(x),cos(x) and tan(x) using this fourmla
http://www.daniweb.com/forums/attachment.php?attachmentid=16080&stc=1&d=1280001204
and the project is says that i can use this fourmla to minmise the computation and increase the efficiency
http://www.daniweb.com/forums/attachment.php?attachmentid=16081&stc=1&d=1280001204
so my first question, when i use the first fourmla, then how can i use the second one?
please give me a simple example (please notice that i'm really poor in math)
* * * * *
my second question,
this is my function to approximate sin(x)
float sin(float x)
{
float result = x;
int limit = 15;
int sign = -1;
for(int i=3 ; i<limit ; i+=2,sign=-sign)
result += sign*result*(x*x)/(i*(i-1));
return result;
}
and this to approximate cos(x)
float cos(float x)
{
float result = 1;
int limit = 15;
int sign = -1;
for(int i=2 ; i<limit ; i+=2,sign=-sign)
result += sign*result*(x*x)/(i*(i-1));
return result;
}
but the answer is not clear in some cases and in other cases it displays wrong answers
try to input 1.5707963
cos should equals to 0.0000000
but my function shows -0.263853, so the answer is not that good
waiting for you