0
$\begingroup$

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

  • 0
    The sum should start at $n = 0$, not $i = 0$.2012-11-23

4 Answers 4

0

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!

  • 0
    @Eran see above :)2012-11-23
0

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

0

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

  • 1
    oh sorry, see http://en.wikipedia.org/wiki/Taylor's_theorem about remainders and you can estimate error of calculation depending on n.2012-11-23
0

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