Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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|improve this question
1  
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
add comment

4 Answers

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|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
add comment

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

share|improve this answer
add comment

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++.

share|improve this answer
    
thanks mate, but I don't speak russian –  Georgey Nov 23 '12 at 10:15
1  
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
add comment

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|improve this answer
add comment

Your Answer

 
discard

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.