# When calculating Taylor Series of cos(x) what is the meaning on the index n?

I mean, when I calculate with my calculator $\cos(1)=0.99984769515639$, what is the $n$ for this calculation?

I ask the question because I was asked to write a function in C++ to calculate $\cos(x)$ but I can't understand the use of the indexer in the series.

I know that the series looks like this:

$$\cos(x) =\sum_{i=0}^\infty {(-1)^n{x^{2n}}\over(2n!)}$$

Let's say I want to calculate $\cos(1)$ by hand, how would I do it using Taylor Series, what would be in $n$?

-
The sum needs editing –  Amr Nov 23 '12 at 9:57
Sum has been edited :) –  Epictetus Nov 23 '12 at 9:59
the two formulas are equivalent, the one I used was from Wikipedia... –  Georgey Nov 23 '12 at 10:00
The sum should start at $n = 0$, not $i = 0$. –  Antonio Vargas Nov 23 '12 at 11:42

## 4 Answers

The number of terms will depend on just how close you want the sum to approximate the true value of $\cos(1)$. As n increases, the absolute value of the terms becomes vanishingly small due to the factorial term in the denominator. Try it and see!

-
so if I want to get as close as possible to the result in my calculator, what n would I choose? –  Georgey Nov 23 '12 at 10:08
@Eran see above :) –  Epictetus Nov 23 '12 at 10:25

Hint: Use Taylor's theorem to get an estimate for the error.

-

n should be enough big. ) Using taylor series you can found approximate value of cos(). On wiki (http://ru.wikipedia.org/wiki/%D0%FF%E4_%D2%E5%E9%EB%EE%F0%E0) you can find some formulas for residual member (remainder) of taylor series.(see "Формула Тэйлора" , "Различные формы остаточного члена") Residual member(remainder) depends on n which you use for calculation and you can estimate error of calculation cos in c++.

-
thanks mate, but I don't speak russian –  Georgey Nov 23 '12 at 10:15
oh sorry, see en.wikipedia.org/wiki/Taylor's_theorem about remainders and you can estimate error of calculation depending on n. –  AlekseyM Nov 23 '12 at 10:28

The number of terms will depend on the degree of accurance you want for example if you want to determine the first 10 digits of $\cos(x)$ you find any n such that $x^{n+1}/(n+1)!\le 10^{-11}$ so if you want to calculate $\cos(x)$ where $x \le 1$ then 13 terms are enough to calculate the first 10 digits of $\cos(x)$

-