# Approximating the cosine by Taylor polynomial

Let $f:=\cos(x)$ I'm asked to find for which values of $x$ we can be sure the 4th degree Taylor polynomial will give an error lesser than $\frac{1}{1000}$.

Now, $\cos(x)=1-\frac{x^2}{2}+\frac{x^4}{24}+o(x^4)$

Taylor's 4th degree remainder is then $R=\frac{f^{(5)}(\cos(\theta))}{5!}x^5=\frac{-\sin(\theta)}{5!}x^5$

Since I'm only asked about the error, I can get rid of the sign, and can do the following boundering:

$|R|\leq|\frac{1}{5!}x^5|\leq\frac{1}{1000}$

Since that is strictly increasing, its easy to solve that last inequation, by doing $\frac{1}{120}x^5=\frac{1}{1000}\longrightarrow x=\sqrt{\frac{120}{1000}}\approx0.65$

Which ends up giving $|R|\leq\frac{1}{1000}\forall x:|x|\leq\sqrt{\frac{120}{1000}}(\approx0.65)$

Now, I thought this was an already correct solution, but to my surprise, I checked plotted both the function and its Taylor polynomial, and the error bound that produces below $0.65$ is not only lesser than $\frac{1}{1000}$, but actually lesser than $\frac{1}{10000}$

e.g: $$\cos(0.65)=0.796187...$$ $$taylor(cos(0.65))=0.796083...$$

Which means it is overly precise, what is going on here, I'm asuming it must be some arithmetic mistake I made somewhere, but I can't find it and its driving me crazy.

## 2 Answers

You made us of $|\sin\theta|\le 1$ in your derivation, which is a very conservative estimate and fine. Once you notice that in fact $|\sin\theta|\le|\theta|\le |x|$, you can try to find the bounds for $x$ from $\left|\frac{x^6}{5!}\right|<\frac1{1000}$, which will allow you to go up to $0.7023\ldots$ instead of just $0.65$.

Still, the fact that Taylor guarantees you an error $<\frac1{1000}$ does not exclude the possibility that the error is indeed much smaller "by chance".

• Thanks for the better approach Hagen, I was indeed considering the fact that the actual error would be obviously smaller, but I found it surprising that it was almost exactly 10 times more precise than I was seeking for, which made me think I had made some mistake. – F.Webber Apr 21 '14 at 18:15
• The factor $\approx0.1$ is even better explained by @mixedmath's additional factor $\frac x6\approx 0.11$ of the first omitted term (as the summands have alternating sign and are strictly decreasing in absolute value) – Hagen von Eitzen Apr 21 '14 at 19:57

You have given an upper bound for the error, so you shouldn't be surprised that the actual error is below it. Further, you gave away more than you could have by assuming that $\sin(\theta)$ gets as large as $1$ in your interval, which it doesn't.

So that's to say that nothing is wrong, and the trivial upper bound is exactly that - trivial.

On the other hand, there is a better trivial upper bound. The cosine expansion is alternating, the terms go to $0$, are decreasing in size (which isn't immediately obvious, nor true for all ranges of $x$ - but it is true here). So you can recognize that the error will be less than the first omitted term.

The first omitted term is $x^6/6!$. At $x=.65$, this is about $.0001$, or $1/10000$, as you've requested.

Since the terms of the cosine expansion quickly decay, this alternating series error should be pretty accurate very often.

• Thanks man, yes I was already expecting lower errors as this is an upper bound as you said, but the fact that I found surprising is that it was 10 times more precise than I was seeking for. But now that you say it, it does indeed decay pretty quickly, which I guess explain why its so precise. – F.Webber Apr 21 '14 at 18:18