First, sorry if this post is off-topic. I consider it too analytic for stack overflow.
In Numerical Analysis subject I must explain which one is better (has less error). The recursive implementation seems to be better with the inputs I have used, but I don't know the reason.
Can someone explain to me which one is better and why? Having in mind round-off error and loss of significance using doubles.
Iterative implementation:
$$\cos{x} = 1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} + \ ... \ + (-1)^n\frac{x^{2n}}{(2n)!}$$
Recursive implementation:
$$y_{n+1} = (-1)^n$$ $$y_{k} = \frac{y_{k+1}x^2}{(2k)(2k-1)} + (-1)^{k-1}, \ \text{for} \ k=n,\ n-1,\ n-2,\ ... \ 1$$