Calculating Taylor Polynomial and its error

71 Views Asked by At

there is an extension question I am trying to solve for my exam revision. It reads Use an appropriate Taylor polynomial for sin x and apply the Taylor’s formula for the remainder to approximate $\sin(72)$ to four decimal place accuracy.

I have a rough idea which is to use the fact that $\sin(x)$ can be represented as $$\sum_{n = 0}^\infty \frac{(-1)^n}{(2n+1)!} x^{2n+1}$$

But I'm still really lost. Could someone please solve it for me. Thanks

2

There are 2 best solutions below

2
On

If you take the series and work it out

$$ \sum_{n=0}^{\infty} \frac{(-1)^{n}}{(2n+1)!}x^{2n+1} = x - \frac{x^{3}}{3!} + \frac{x^{5}}{5!} - \cdots \tag{1}$$

convert to radians $72^{\circ} \times \frac{\pi}{180} = \frac{2\pi}{5} $

$$ \sin(\frac{2\pi}{5}) \approx \frac{2\pi}{5} - \frac{(\frac{2\pi}{5})^{3}}{3!} + \frac{(\frac{2\pi}{5})^{5}}{5!} \approx .9518 \tag{2} $$

$$ \sin(\frac{2\pi}{5}) \approx \frac{2\pi}{5} - \frac{(\frac{2\pi}{5})^{3}}{3!} + \frac{(\frac{2\pi}{5})^{5}}{5!} - \frac{(\frac{2\pi}{5})^{7}}{7!} \approx .951035 \tag{3}$$

$$ \sin(\frac{2\pi}{5}) \approx .951056 \tag{4} $$

If you let the first approximation equal $T_{3}$ and second equal $T_{4}$ and call $\sin(\frac{2\pi}{5}) = T$ we get

$$ T - T_{3} \approx -0.0007 \tag{5} $$

$$ T - T_{4} \approx 0.0000215 \tag{6} $$

and check

import math

my_v = (2/5)*math.pi

approx = my_v - (my_v**3)/math.factorial(3) + (my_v**5)/math.factorial(5) - (my_v**7)/math.factorial(7) 

my_value = math.sin(my_v)

my_difference = math.fabs(my_value-approx)

approx
Out[12]: 0.951035288276224

my_difference
Out[13]: 2.1228018929564385e-05

my_value
Out[14]: 0.9510565162951535
1
On

You want to know $p$ such that using $$\sum_{n = 0}^\infty \frac{(-1)^n}{(2n+1)!} x^{2n+1}=\sum_{n = 0}^p \frac{(-1)^n}{(2n+1)!} x^{2n+1}+\sum_{n = p+1}^\infty \frac{(-1)^n}{(2n+1)!} x^{2n+1}$$ Since it is an alternating series, the error will be given by the first neglected term and so, you want $$R_p=\frac{x^{2p+3}}{(2p+3)!} \leq \epsilon\qquad \text{with}\qquad x=\frac{2\pi}5$$ Since you are not asked for an high accuracy $\epsilon=10^{-4}$, just compute for the first values of $p$.