# How to evaluate $\int_0^1 \mathrm e^{-x^2} \,\mathrm dx$ using power series?

I'm trying to evaluate $$\int_0^1 \mathrm e^{-x^2} \, \mathrm dx$$ using power series.

I know I can substitute $x^2$ for $x$ in the power series for $\mathrm e^x$: $$1-x^2+ \frac{x^4}{2}-\frac{x^6}{6}+ \cdots$$ and when I calculate the antiderivative of this I get $$x-\frac{x^3}{3}+ \frac{x^5}{5\cdot2}-\frac{x^7}{7\cdot6}+ \cdots$$

How do I evaluate this from $0$ to $1$?

• Also, please look at this post where someone shows how to go about doing this. – Andrew Tawfeek Aug 24 '17 at 0:48
• Due to the alternating signs, the value of the last series is between $\frac{2}{3}$ and $\frac{2}{3}+\frac{1}{10}$. – Jack D'Aurizio Aug 24 '17 at 0:48
• – Clement C. Aug 24 '17 at 1:02
• "Theorems on power series withing their radius of convergence." Basically, power series: inside the radius of convergence, everything works. – Clement C. Aug 24 '17 at 1:03
• Agreed, and here the radius of convergence is $+\infty$, hence we are pretty comfortable in performing such manipulations. – Jack D'Aurizio Aug 24 '17 at 1:05

Just collecting the material in the comments and converting it into answer. We have $$e^{-x^2}=\sum_{n\geq 0}\frac{(-1)^n x^{2n}}{n!}$$ where the series in the RHS is absolutely convergent for any $x\in\mathbb{R}$, since $e^{-x^2}$ is an entire function. If we apply $\int_{0}^{1}(\ldots)\,dx$ to both sides we get $$\int_{0}^{1}e^{-x^2}\,dx = \sum_{n\geq 0}\frac{(-1)^n}{n!(2n+1)}$$ since the absolute convergence is more than enough to ensure we are allowed to exchange $\int$ and $\sum$. The last series has terms with alternating signs which are decreasing in absolute value, hence the numerical value of such series is between any two consecutive partial sums. For instance, by considering the partial sums up to $n=1$ and $n=2$ we get $$I=\int_{0}^{1}e^{-x^2}\,dx \in \left(\frac{2}{3},\frac{2}{3}+\frac{1}{10}\right).$$
Can we improve such approximation in a slick way? Yes, of course. For instance, through integration by parts and a bit of patience we may check that $$\int_{0}^{1}\underbrace{\left(\frac{16}{93}x^4(1-x)^4+\frac{8}{9}x^3(1-x)^3\right)}_{\in\left[0,\frac{1}{68}\right]\text{ for any }x\in[0,1]}e^{-x^2}\,dx = \frac{100}{279}-\frac{44}{93} I$$ hence the actual value of $I$ is quite close to $\frac{100}{279}\cdot\frac{93}{44}=\color{blue}{\large\frac{25}{33}}$. Actually the error function has a well-known continued fraction expansion from which it is simple to derive the more accurate approximation $\color{blue}{\large\frac{56}{75}}$. $I\geq e^{-1/3}$ is a straightforward consequence of Jensen's inequality. By replacing the polynomials $x^3(1-x)^3$ and $x^4(1-x)^4$ with suitable multiples of the shifted Legendre polynomials $P_4(2x-1)$ and $P_5(2x-1)$ we get the remarkable approximation $I\approx\color{blue}{\large\frac{6171}{8263}}$ which differs from the exact value by less than $10^{-6}$, but the best rational approximation with such accuracy is $\color{blue}{\large\frac{823}{1102}}$.
$$\left[ x-\frac{x^3}{3}+ \frac{x^5}{5*2}-\frac{x^7}{7*6}+ \dots \right]_0^1 = \left( 1-\frac{1}{3} + \frac{1}{5 \cdot 2} - \frac{1}{7 \cdot 6} + \dots \right) - 0 = \sum_{n=0}^\infty \frac{(-1)^{n}}{(2n+1)n!}$$
So $\int_{0}^{1}e^{-x^2}=\sum_{n=0}^\infty \frac{(-1)^{n}}{(2n+1)n!}$, that is, the answer is whatever the series converges to.
So, write $$\int_{0}^{1}e^{-x^2}=\sum_{n=0}^{p-1} \frac{(-1)^{n}}{(2n+1)n!}+ R_p$$ and you want $$R_p=\frac{1}{(2p+1)p!} \leq 10^{-k}\implies (2p+1)p! \geq 10^{k}\implies \log\left((2p+1)p!\right) \geq \log(10^{k})$$ If you look at the plot of the last rhs, you will notice that it looks like a power law and a very simpler regression will give (for $1 \leq p \leq 20$) $$\log\left((2p+1)p!\right)\approx 0.831352\, p^{1.34007}$$ which will then give $$p \approx 2.13873\, k^{0.74623}$$ So, using for example, $k=6$, this would give $p=8.144$; then say $p=9$. Checking $$17 \times 8!=685440 <10^6$$ $$19 \times 9!=6894720 >10^6$$ So, computing the terms by the summation up to $p=8$,we should get $$\frac{1098032417}{1470268800}\approx 0.74682427$$ while the exact value would be $\frac{\sqrt{\pi }}{2} \text{erf}(1)\approx 0.74682413$.