TITLE: How to calculate the integral in normal distribution?
QUESTION [23 upvotes]: The factory is making products with this normal distribution: $\mathcal{N}(0, 25)$.
What should be the maximum error accepted with the probability of 0.90?
[Result is 8.225 millimetre]
How will I calculate it?
How to integrate:  $\exp\left(- \frac{x^2}{2} \right)$  ?

REPLY [28 votes]: There are several ways to compute the cumulative normal distribution.

Simple Series Integration
First of all, we can start with
$$
e^{-x^2/2}=1-\frac{x^2}{2^1\cdot1!}+\frac{x^4}{2^2\cdot2!}-\frac{x^6}{2^3\cdot3!}+\dots
$$
and integrate to get
$$
\begin{align}
\frac1{\sqrt{2\pi}}\int_0^xe^{-t^2/2}\,\mathrm{d}t
&=\frac1{\sqrt{2\pi}}\left(x-\frac{x^3}{3\cdot2^1\cdot1!}+\frac{x^5}{5\cdot2^2\cdot2!}-\frac{x^7}{7\cdot2^3\cdot3!}+\dots\right)\\
&=\frac1{\sqrt{2\pi}}\sum_{k=0}^\infty(-1)^k\frac{x^{2k+1}}{(2k+1)2^kk!}
\end{align}
$$

Unilateral Power Series
To get a series with no sign changes, write
$$
\Omega(x)=e^{x^2/2}\int_0^xe^{-t^2/2}\,\mathrm{d}t
$$
and note that
$$
\Omega'(x)=1+x\Omega(x)
$$
which leads to the following recursion for the coefficients
$$
a_{n+2}=\frac{a_n}{n+2}
$$
Because $\Omega(0)=0$ and $\Omega'(0)=1$, we get
$$
\begin{align}
\frac1{\sqrt{2\pi}}\int_0^xe^{-t^2/2}\,\mathrm{d}t
&=\frac1{\sqrt{2\pi}}e^{-x^2/2}\Omega(x)\\
&=\frac1{\sqrt{2\pi}}e^{-x^2/2}\sum_{k=0}^\infty \frac{x^{2k+1}}{(2k+1)!!}
\end{align}
$$

Asymptotic Expansion
The terms of the convergent series above can get quite big as $x$ gets big, so let's compute an asymptotic expansion for the tail.
Consider
$$
\begin{align}
\int_x^\infty e^{-t^2/2}\,\mathrm{d}t
&=\int_0^\infty e^{-(t+x)^2/2}\,\mathrm{d}t\\
&=e^{-x^2/2}\int_0^\infty e^{-xt-t^2/2}\,\mathrm{d}t\\
&=\frac{e^{-x^2/2}}{x}\int_0^\infty e^{-u-u^2/(2x^2)}\,\mathrm{d}u\\
&=\frac{e^{-x^2/2}}{x}\int_0^\infty e^{-v}u'\,\mathrm{d}v\\
\end{align}
$$
where $v=u+\dfrac{u^2}{2x^2}$; that is, $u=x^2\left(\sqrt{1+2v/x^2}-1\right)$. Using the binomial theorem, to expand $\sqrt{1+2v/x^2}$, we get
$$
\frac1{\sqrt{2\pi}}\int_x^\infty e^{-t^2/2}\,\mathrm{d}t
\sim\frac1{\sqrt{2\pi}}e^{-x^2/2}\sum_{k=0}^\infty\frac{(-1)^k(2k-1)!!}{x^{2k+1}}
$$
where $(-1)!!=1$.
Note that this series is not convergent, but asymptotic.