[Math] Approximating the cosine by Taylor polynomial

real-analysistaylor expansion

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[5]{\frac{120}{1000}}\approx0.65$

Which ends up giving $|R|\leq\frac{1}{1000}\forall x:|x|\leq\sqrt[5]{\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.

Best Answer

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.

Related Question