# How to compute $\int_0^1 {e^{-x^2}} dx$

I know that $$\int_{0}^{+ \infty} e^{- x^{2}} dx = \frac{\sqrt{\pi}}{2}.$$

My question is: $$\int_{0}^{1} e^{- x^{2}} dx = ~?$$

-
I think one can only do it numerically. – Jack Sep 19 '11 at 3:36
Well, there are ways to numerically compute the error function, much as you'll need a numerical method to compute $\sin\,1$... – J. M. Sep 19 '11 at 3:40

$\mathrm{erf}(z)$ is the "error function" encountered in integrating the normal distribution (which is a normalized form of the Gaussian function). It is an entire function defined by $$\mathrm{erf}(z)=\frac{2}{\sqrt{\pi}}\int_{0}^{z}e^{-t^2}\mathrm{dt}$$ Note that some authors (e.g., Whittaker and Watson 1990, p. 341) define $\mathrm{erf}(z)$ without the leading factor of $2/\sqrt{\pi}$.

Your question's solution is $$\int_{0}^{1}e^{-r^2}\mathrm{dr}=\frac{\sqrt{\pi}}{2}\mathrm{erf}(1)$$

You can get approximate value by using series $$\mathrm{erf}(x)=\frac{e^{-x^2}}{\sqrt{\pi}}\sum^{\infty}_{n=0}\frac{(2x)^{2n+1}}{(2n+1)!!}$$

Hope this helped.

Added. approximate value of $\mathrm{erf}(1)$ with 20 digits is

$\mathrm{erf}(1)\approx0.84270079294971486934$.

so the value is

$$\int_{0}^{1}e^{-r^2}\mathrm{dr}\approx0.74682413281242702540$$

-
You could also use the series $$\int_0^x e^{-r^2}\ dr = \sum_{k=0}^\infty \frac{(-1)^k x^{2k+1}}{k!(2k+1)}$$ – Robert Israel Sep 19 '11 at 4:35
I prefer the series ks0830 used to the usual Maclaurin series; it's less prone to subtractive cancellation. – J. M. Sep 19 '11 at 15:21
When I have to eveluate an alternating series like this, I either separately accumulate the positive and negative terms or see if, for large enough $n$, $a_{2n}-a_{2n+1}$ has constant sign. – marty cohen Dec 23 '12 at 22:13
@J.M.: I show these two methods and an asymptotic expansion here. – robjohn Dec 24 '12 at 9:57

Since $$e^{-x^2}=\sum_{k=0}^\infty\frac{(-x^2)^k}{k!}$$ we get by integrating that $$\int_0^te^{-x^2}\,\mathrm{d}x=\sum_{k=0}^\infty(-1)^k\frac{t^{2k+1}}{(2k+1)k!}$$ Therefore, $$\int_0^1e^{-x^2}\,\mathrm{d}x=\sum_{k=0}^\infty\frac{(-1)^k}{(2k+1)k!}$$ which converges pretty quickly.

Unilateral Power Series

A bit more complicated, yet yielding a non-alternating series, is to note that if we define $$f(x)=e^{x^2}\int_0^xe^{-t^2}\,\mathrm{d}t$$ Then $f'(x)=1+2xf(x)$ and $$f(x)=\sum_{k=0}^\infty a_kx^k$$ yields $2a_{k-1}=(k+1)a_{k+1}$. Using $f(0)=0$ and $f'(0)=1$ gives $a_{2k+1}=\dfrac{2^k}{(2k+1)!!}$. Thus, $$\int_0^xe^{-t^2}\,\mathrm{d}t=e^{-x^2}\sum_{k=0}^\infty\frac{2^kx^{2k+1}}{(2k+1)!!}$$ Therefore, $$\int_0^1e^{-t^2}\,\mathrm{d}t=e^{-1}\sum_{k=0}^\infty\frac{2^k}{(2k+1)!!}$$

-
Nice to see the double factorial popping up every so often... :) – J. M. Jan 16 '13 at 17:19

According to Laplace, Legendre and the two masters of continued fractions, Jacobi and Ramanujan, $$\int_{0}^{1} e^{- x^{2}} \,d{x} = \frac{\sqrt{\pi}}{2} - \cfrac{\frac{1}{2} e^{-1}}{1 + \cfrac{1}{2 + \cfrac{2}{1 + \cfrac{3}{2 + \cfrac{4}{1 + \cfrac{5}{2 + \cdots}}}}}}.$$

-