1

In a series expansion of the definite integral $$\int^{1}_{0}e^{-x^2}dx,$$

how many terms of this series are necessary to approximate this integral to within $0.01$.

What I tried:

\begin{align} \int^{1}_{0}e^{-x^2}dx &=\int^{1}_{0}\sum^{\infty}_{n=0}\frac{(-1)^nx^{2n}}{n!}dx \\ &=\sum^{\infty}_{n=0}\frac{(-1)^n}{n!}\int^{1}_{0}x^{2n}dx \\ &=\sum^{\infty}_{n=0}\frac{(-1)^n}{(2n+1)n!} \end{align}

Could someone help me? How many terms are used to approximate this integral within $0.01$?

Thanks.

Gonçalo
  • 15,869
jacky
  • 5,345

3 Answers3

4

For an alternating series where the terms decrease in absolute value, the remainder (i.e., the error between the partial sum and the infinite sum) is always bounded by the absolute value of the next term left out of the partial sum. See here for instance.

You have calculated that the integral is equal to the alternating series $\sum_{n=0}^\infty \frac{(-1)^n}{(2n+1)n!}$, and so using the above fact you know: \begin{align*} \left| \sum_{n=0}^\infty \frac{(-1)^n}{(2n+1)n!} - \sum_{n=0}^N \frac{(-1)^n}{(2n+1)n!}\right| &\leq \frac{1}{(2N+1)N!}\\ \left|\int_0^1 e^{-x^2} \ dx - \sum_{n=0}^N \frac{(-1)^n}{(2n+1)n!}\right| &\leq \frac{1}{(2N+1)N!}\\ \end{align*}

So you just need to find the smallest $N$ so that $\frac{1}{(2N+1)N!} \leq 0.01$.

kccu
  • 21,188
1

Well, as you showed the integral is equal to:

$$\int\limits_0^1\exp\left(-x^2\right)\space\text{d}x=\sum_{\text{n}\space\ge\space0}\frac{\left(-1\right)^\text{n}}{\left(2\text{n}+1\right)\left(\text{n}!\right)}=\frac{\text{erf}\left(1\right)\sqrt{\pi}}{2}\approx0.746824132812427\tag1$$

Where $\displaystyle\text{erf}\left(x\right)$ is the error function.

So, you're trying to find:

$$\left|\int\limits_0^1\exp\left(-x^2\right)\space\text{d}x-\sum_{\text{n}\space=\space0}^\text{k}\frac{\left(-1\right)^\text{n}}{\left(2\text{n}+1\right)\left(\text{n}!\right)}\right|<\frac{1}{100}\space\Longleftrightarrow\space\text{k}=\dots\tag2$$

Jan Eerland
  • 29,457
1

Write $$\sum^{\infty}_{n=0}\frac{(-1)^n}{(2n+1)n!}=\sum^{p}_{n=0}\frac{(-1)^n}{(2n+1)n!}+\sum^{\infty}_{n=p+1}\frac{(-1)^n}{(2n+1)n!}$$

Since it is alternating, you need to find $p$ such that $$\frac{1}{(2 p+3) (p+1)!} \leq \epsilon \tag 1$$ that is to say $$(2 p+3) (p+1)! \geq \frac 1 \epsilon$$ To make it simpler, replace the $3$ by $4$ and consider then the problem of $$(p+2)! \geq \frac 1{2 \epsilon} \tag 2$$ Now, have a look at the superb approximation @Gary gave here.

Applied to your case $$\large\color{blue}{p \sim -\frac{\log \left(2\epsilon \sqrt{2 \pi } \right)}{W\left(-\frac{1}{e}\log\left(2\epsilon \sqrt{2 \pi } \right)\right)}-\frac 52}$$ where $W(.)$ is the principal branch of Lambert function.

Using $\epsilon=10^{-16}$ gives, as a real $p=15.9144$ while the exact solution of $(1)$ is $p=15.9249$. Notice that the exact solution of $(2)$ is $p=15.9152$