"decode" an aproximation of sin Taylor series
I'm using Taylor series to compute sin(). The Taylor series for the sin are:
The implementation I'm using looks like follows:
float sine(float x, int j)
{
float val = 1;
for (int k = j - 1; k >= 0; --k)
val = 1 - x*x/(2*k+2)/(2*k+3)*val;
return x * val;
}
As far I understand, that code is an aproximation of j terms of the
polynomial (In other words, the aproximation is a sumatory from zero to j
instead of from zero to ‡), k is n in the formula, and of course x is x.
I'm trying to understand that implementation, that is, the transformation
from the formula above to the code. My goal is to write the same kind of
implementation for the cos() series.
Could you help me to understand that? Thanks
No comments:
Post a Comment