Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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$?

share|cite|improve this question
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
up vote 0 down vote accepted

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!

share|cite|improve this answer
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.

share|cite|improve this answer

n should be enough big. ) Using taylor series you can found approximate value of cos(). On wiki ( 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++.

share|cite|improve this answer
thanks mate, but I don't speak russian – Georgey Nov 23 '12 at 10:15
oh sorry, see'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)$

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.