0

For $f(x) = xe^{-x^{2}}$ the taylor series is given by $$\sum_{n=0}^{\infty}\frac{(-1)^{n} x^{2n + 1}}{n!}.$$

How many terms are necessary to approximate $f(1)$ to $10^{-6}$ accuracy?


If we define the partial sum $s_{k, x =1} = \sum_{n = 0}^{k} \frac{(-1)^{n} }{n!}$, I think I just need to find the minimum value of $k$ so that

$$|s_{k} - e^{-1}| < 10^{-6}$$

Is there a way to find this without bruteforce?

1 Answers1

1

You must take into account that this is an alternating series. So, considering $$\sum_{n=0}^{\infty}\frac{(-1)^{n} x^{2n + 1}}{n!}=\sum_{n=0}^{p}\frac{(-1)^{n} x^{2n + 1}}{n!}+\sum_{n=p+1}^{\infty}\frac{(-1)^{n} x^{2n + 1}}{n!}$$ you need to find (since $x=1$) the value of $p$ such that $$\frac 1{(p+1)!} < 10^{-k}\implies (p+1)! =10^k$$ If you look at this question of mine, you will see a magnificent approximation by @robjohn for the inverse of the factorial function.

Using $a=1$, you should get $$p+1=\frac{2 k \log (10)-\log (2 \pi )}{2 W\left(\frac{2 k \log (10)-\log (2 \pi )}{2 e}\right)}-\frac 12 \implies \color{blue}{p=\frac{2 k \log (10)-\log (2 \pi )}{2 W\left(\frac{2 k \log (10)-\log (2 \pi )}{2 e}\right)}-\frac 32}$$ where appears Lambert function.

Since the argument is quite large, you can evaluate Lmabert function using $$W(t)=L_1-L_2+\frac{L_2}{L_1}+\frac{L_2(L_2-2)}{2L_1^2}+\frac{L_2(6-9L_2+2L_2^2)}{6L_1^3}+\cdots$$ where $L_1=\log(t)$ and $L_2=\log(L_1)$ (as given in the linked Wikipedia page).

Fo $k=6$, this will give $p=8.44$; so take $p=9$. Just checking $9!=362880 < 10 ^6$ and $10!=3628800> 10^6$.