3
$\begingroup$

I'm working on a problem:

Compute cos(5°) to 5 decimal places with Maclaurin's Series

I know that that function cos(x) has a Mclaurin representation of:

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

The only part I am unsure of is how to find out many terms n to choose.

I'm not sure if I am supposed to use the alternating series estimation or taylor series estimation or what.

$\endgroup$
1
  • 1
    $\begingroup$ You wanna use an error estimator to find the least number of terms you'll need to compute. For instance the Lagrange form of the remainder. $\endgroup$
    – Git Gud
    Apr 19, 2013 at 19:18

3 Answers 3

6
$\begingroup$

As you've stated

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

If you want to express this as an order $N$ polynomial plus a remainder, you split the summation as follows:

$$ \cos(x) = \sum_{n=0}^N \frac{(-1)^n (x)^{2n}}{(2n)!} + \sum_{n=N+1}^\infty \frac{(-1)^n (x)^{2n}}{(2n)!} $$ $$ = \sum_{n=0}^N \frac{(-1)^n (x)^{2n}}{(2n)!} + R_N(x) $$

If the remainder is convergent, then it is bounded by it's first term because it is an alternating series. For an alternating series to be convergent, it is sufficient for the magnitude of the sequence of terms to approach zero, which our remainder clearly does for any finite value of $x$ (the factorial grows like $n^n$, which is faster than any exponential growth $x^n$ for a fixed $x$). So the alternating series bound applies: $$ |R_N(x)|\leq \frac{x^{2(N+1)}}{(2(N+1))!} $$

So for your $x=5^\circ$ (make sure you convert to radians before you use it) and precision of five decimal places (say you want $|R_N|\leq10^{-6}$), you can solve for $N$ that gives you that. That's how you pick how many terms to keep.

Edit

In general it is hard to "invert" a factorial, so perhaps I was a bit misleading about "solving" that equation for $N$. You can however guess and check values until you get to the threshold you picked.

$\endgroup$
6
  • $\begingroup$ How do you handle the N factorial when solving this equation? I've set this less than or equal to 10E-6. $\endgroup$ Apr 19, 2013 at 19:32
  • $\begingroup$ Usually you just plug in N=1, N=2, etc. until you get a number smaller than your cutoff. Solution by brute force :-) $\endgroup$
    – rajb245
    Apr 19, 2013 at 19:34
  • $\begingroup$ You can shave a little effort off of that if you know some factorial values. We would like $\frac{x^{2N+2}}{(2N+2)!} \le 10^{-6} \Rightarrow \frac{(2N+2)!}{x^{2N+2}} \ge 10^6 $ with $x \approx 0.1$ (good enough for this sort of estimation). So we want $(2N+2)! \cdot 10^{2N+2} \ge 10^6 $ . Using $N = 2$ would already make the exponential factor $10^6$, so we don't need it to be larger than that. On the other hand, $N = 1$ only gives us $3! \cdot 10^4 = 60,000$. So $N = 2$ should do the job. It's not quite brute force since we can get a really good first guess pretty quickly. $\endgroup$ Apr 19, 2013 at 23:26
  • 1
    $\begingroup$ You don' need to use the alternating series remainder theorem to bound this, you can use more easily the lagrange's or taylor inequality. (Though the alternating series is usually easier). $\endgroup$
    – john
    Jan 6, 2020 at 3:45
  • 1
    $\begingroup$ "The remainder is bounded by it's first term for an alternating series": this is only true if the terms of the remainder are decreasing in absolute value. True here, but it is worth making explicit. $\endgroup$
    – TonyK
    Sep 5, 2020 at 17:25
3
$\begingroup$

Use the alternating series estimate. When it is available it is often (i) a lot easier to use and (ii) sharper than the estimate based on the Lagrange form of the remainder.

When you use the alternating series estimate, you will find that the $\frac{x^4}{4!}$ term is very very small. Cutting off after the $\frac{x^2}{2!}$ term gets you much more accuracy than you need.

$\endgroup$
2
  • $\begingroup$ Do I substitute in 5pi/180 for X or 5 degrees? In other words, does it matter if I use degrees or radians? $\endgroup$ Apr 19, 2013 at 19:28
  • $\begingroup$ You must use radians, so $x=\frac{\pi}{180}$. The function $\cos x$ that you know the expansion of takes radian inputs. You could define a new function $\operatorname{Cos}{x}$ that takes degree inputs. Its power series expansion is a relative of the familiar expansion of $\cos x$, but different. $\endgroup$ Apr 19, 2013 at 19:38
1
$\begingroup$

You can simply choose enough terms until the 5th decimal place does not change anymore. Since the terms of this sum get smaller in magnitude as n approaches infinity, once the absolute value of the nth term is less than $10^{-5}$, the fifth decimal place should not change in the subsequent terms.

$\endgroup$
1
  • 1
    $\begingroup$ It's not that the terms get smaller that gives the series this property, it's that they get smaller AND alternate. $\endgroup$
    – rajb245
    Apr 19, 2013 at 19:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .