TITLE: Using numerical methods to calculate integral
QUESTION [5 upvotes]: $$
\mbox{How can I go about calculating}\quad
\int_{0}^{\infty}\,{\rm e}^{-100\,x^{2}}\,{\rm d}x\quad 
\mbox{to}\ {\sf\mbox{five}}\ \mbox{decimal places of accuracy ?.}
$$
Do I use Simpson's Rule ?. If so, wouldn't calculating the fourth derivative be a pain, and what about maximums ?.

REPLY [6 votes]: Since we want to approximate:
$$ I = \frac{1}{10}\int_{0}^{+\infty}e^{-x^2}\,dx $$
it is enough to have an approximation for:
$$ J = \int_{0}^{4}e^{-x^2}\,dx,\tag{1} $$
since:
$$ \int_{4}^{+\infty}e^{-x^2}\,dx = e^{-16}\int_{0}^{+\infty}e^{-8x-x^2}\,dx \leq \frac{1}{8e^{16}}.$$
To achieve a good approximation for $(1)$, it is sufficient to integrate termwise the Taylor series of $e^{-x^2}$:
$$e^{-x^2} = \sum_{k=0}^{+\infty}\frac{(-1)^k}{k!}x^{2k}, $$
$$\int_{0}^{4}e^{-x^2}\,dx = \sum_{k=0}^{+\infty}\frac{(-1)^k 4^{2k+1}}{(2k+1)k!}.\tag{2}$$
By Leibniz' rule, we just need to find a $k$ such that:
$$\frac{4^{2k+1}}{(2k+1)k!}<10^{-4}.$$
With some rather crude bound for $k!$, it is not difficult to prove that $k=50$ is enough, so:
$$ I \approx \frac{1}{10}\sum_{k=0}^{50}\frac{(-1)^k 4^{2k+1}}{(2k+1)k!}.\tag{3}$$