# Taylor Series - approximation of $\sin(x)$

What polynomial degree should be taken in the function $$f(x) = \sin(x)$$ so that the largest modulus of the difference between the value of the Taylor polynomial and the value of the $$\sin(x)$$ function on the $$[0, \frac{\pi}{2}]$$ interval is not greater than $$10^{-17}$$?

I'm not quite sure how to do this task. I started by finding the general form of the Taylor series for $$\sin(x)$$. Then I found the general form of the remainder of the Taylor series as: $$R_n(x) = \frac{\sin(c + \frac{n\pi}{2}) \cdot x^{n+1}}{(n+1)!}$$. Then I constrained this function by $$\frac{x^{n+1}}{(n+1)!}$$. I think I need to calculate this inequality $$\left|\frac{x^{n+1}}{(n+1)!}\right| < 10^{-17}$$, but I have no idea what to take for $$x$$? The extreme values of the interval?

For a given $$n$$, your expression attains its maximum value on the interval when $$x$$ is equal to $$\pi/2$$. So yes, this is the value you should take for $$x$$.

• Thank you so much! May 10 at 21:41

First of all $$\sin(x)=\sum_{n=0}^\infty (-1)^n\,\frac{x^{2n+1}}{(2 n+1)!}$$ to write $$\sin(x)=\sum_{n=0}^p (-1)^n\,\frac{x^{2n+1}}{(2 n+1)!}+\sum_{n=p+1}^\infty (-1)^n\,\frac{x^{2n+1}}{(2 n+1)!}$$

Making the problem more general , you then want to solve for $$p$$ $$\frac {\left(\frac{\pi}{2 }\right)^{2 p+3} }{(2p+3)!} \leq 10^{-k}$$ that is to say $$(2p+3)! \geq \left(\frac{\pi}{2 }\right)^{2 p+3} \,10^k$$

If you look at this old question of mine, you will see an almost exact solution proposed by @robjohn (one of our beloved moderators).

$$p=\frac{\pi }{4}\, e^{1+W(t)}-\frac{7}{4} \qquad \text{where} \qquad t=\frac{2 (k \log (10)-\log (\pi ))}{e \pi }$$ $$W(.)$$ being Lambert function.

Trying for $$k=35$$, this gives $$p=16.67879$$ while the "exact" solution is $$p=16.67897$$.

So, we should use $$p=\lceil 16.67879\rceil=17$$

Checking

$$\frac {\left(\frac{\pi}{2 }\right)^{2 \times 16+3} }{(2\times 16+3)!}=7.0\times 10^{-34} >10^{-35}$$ which is not acceptable.

But

$$\frac {\left(\frac{\pi}{2 }\right)^{2 \times 17+3} }{(2\times 17+3)!}=1.3\times 10^{-36} <10^{-35}$$

For every $$x\in[0,\pi/2]$$ $$\left|\frac{x^{n+1}}{(n+1)!}\right| \le \max_{x\in[0,\pi/2]}\left|\frac{x^{n+1}}{(n+1)!}\right| =\frac{(\pi/2)^{n+1}}{(n+1)!}\;.$$ So you just have to solve $$\frac{(\pi/2)^{n+1}}{(n+1)!}\le10^{-17}\;.$$

• Thank you so much! May 10 at 21:41