\documentclass[a4paper,12pt]{article}
\newcommand{\ds}{\displaystyle}
\newcommand{\pl}{\partial}
\newcommand{\un}{\underline}
\newcommand{\undb}{\underbrace}
\parindent=0pt
\begin{document}


{\bf Question}

The error function ${\rm erf}(x)$ is defined by

$${\rm erf}(x)=1-\ds\frac{2}{\sqrt{\pi}}\ds\int_x^\infty
e^{-t^2}\,dt$$

and is used widely, for example in probability (it's effectively
the cumulative normal distribution) and in boundary layer flow in
fluid dynamics. In this question we prove the Poincar\'e
asymptotic expansion as $x\to+\infty$.

\begin{description}
\item[(i)]
By writing $e^{-t^2}=te^{-t^2} \times \ds\frac{1}{t}$, use
integration by parts to show that

$$\sqrt{\pi}(1-{\rm
erf}(x))=\ds\frac{e^{-x^2}}{x}-\ds\int_x^\infty
\ds\frac{e^{-t^2}}{t^2}\,dt$$

\item[(ii)]
Given that $\sqrt{\pi} \times
\left(\ds\frac{1}{2}\right)\times\left(\ds\frac{3}{2}\right)\times
\left(\ds\frac{5}{2}\right)\times\cdots\times\left(\ds\frac{2n-1}{2}\right)
=\Gamma\left(n+\ds\frac{1}{2}\right)$ iterate this approach to
show that

\begin{eqnarray*} \sqrt{\pi}(1-{\rm erf}(x)) & = & \ds\frac{e^{-x^2}}{\sqrt{\pi}}\left[\sum_{r=0}^n
\Gamma\left(r+\ds\frac{1}{2}\right)\ds\frac{(-1)^r}{x^{2r+1}}\right]+R_n(x)\\
R_n(x) & = &
-\Gamma\left(n+\ds\frac{1}{2}\right)(2n+1)\ds\frac{(-1)^n}{\sqrt{\pi}}\ds\int_x^{\infty}
\ds\frac{e^{-t^2}}{t^{2n+2}}\, dt \end{eqnarray*}

\item[(iii)]
By comparing the integrand of the remainder integral with
$te^{-t^2}$ show that

$$|R_n(x)| \leq
\ds\frac{(2n+1)\Gamma\left(n+\frac{1}{2}\right)}{x^{2n+1}\sqrt{\pi}}\ds\int_x^{\infty}
te^{-t^2}\, dt$$

\item[(iv)]
Hence show that

$$\pi e^{x^2}(1-{\rm erf}(x)) \sim \sum_{r=0}^\infty
\Gamma\left(r+\ds\frac{1}{2}\right)\ds\frac{(-1)^r}{x^{2r+1}},\
x\to+\infty$$

and so deduce that

$${\rm erf}(x) \sim 1-\ds\frac{e^{-x^2}}{\pi} \sum_{r=0}^\infty
\Gamma\left(r+\ds\frac{1}{2}\right)\ds\frac{(-1)^r}{x^{2r+1}},\
x\to+\infty$$

\item[(v)]
For different truncations $N$ use the above approximation to
estimate the value of ${\rm erf}$ for $x=2$, comparing it with the
(numerically obtained) exact result of ${\rm
erf}(2)=0.9953222650189\cdots$ Which truncation gives the best
agreement? Can you explain what happens for higher truncations?
\end{description}

\vspace{.5in}

{\bf Answer}

\begin{description}
\item[(i)]
${\rm erf}(x)=1-\ds\frac{2}{\sqrt{\pi}}\ds\int_x^\infty
e^{-t^2}\,dt$

$\begin{array}{rcl} \Rightarrow \sqrt{\pi}(1-{\rm erf}(x)) & = &
2\ds\int_x^{\infty}e^{-t^2}\, dt\\ & = & 2\ds\int_x^\infty
\undb{\ds\frac{1}{t}}_{\rm diff}\undb{te^{-t^2}}_{\rm int}\, dt\\
& = & 2\left\{\left[\ds\frac{-e^{-t^2}}{2t}\right]_x^\infty
-\ds\frac{1}{2}\ds\int_x^\infty\ds\frac{e^{-t^2}}{t^2}\,
dt\right\}\\ & = & \ds\frac{e^{-x^2}}{x}-\ds\int_x^\infty
\ds\frac{e^{-t^2}}{t^2}\, dt \end{array}$

\item[(ii)]

$\ds \sqrt{\pi}(1-{\rm erf}(x))  =
\frac{e^{-x^2}}{x}-\ds\int_x^{\infty}\ds\frac{1}{t^3}te^{-t^2}\,
dt$

$ =  \ds\frac{e^{-x^2}}{x}+\ds\frac{1}{2}\left[\ds\frac{1}{t^3}
e^{-t^2}\right]_x^{\infty}+\ds\frac{3}{2}\ds\int_x^\infty\ds\frac{1}{t^5}te^{-t^2}\,
dt$

$ =
\ds\frac{e^{-x^2}}{x}-\ds\frac{e^{-x^2}}{2x^3}-\ds\frac{3}{2}\cdot
\ds\frac{1}{2}\left[\ds\frac{1}{t^5}e^{-t^2}\right]_x^\infty
-\ds\frac{3}{2} \cdot \ds\frac{5}{2}\ds\int_x^\infty
\ds\frac{1}{t^7}t e^{-t^2}\, dt$

$ = e^{-x^2}\left[\ds\frac{1}{x}-\ds\frac{1}{2x^3}+\ds\frac{-1}{2}
\cdot \ds\frac{-3}{2}\ds\frac{1}{x^5}\right]
+\left(\ds\frac{-1}{2}\right)
\left(\ds\frac{-3}{2}\right)(-5)\ds\int_x^\infty\ds\frac{1}{t^7}te^{-t^2}\,
dt + \cdots$

$ =
e^{-x^2}\left[\ds\frac{1}{x}-\ds\frac{1}{2x^3}+\left(\ds\frac{-1}{2}\right)
\left(\ds\frac{-3}{2}\right)\left(\ds\frac{1}{x^5}\right)+\cdots\right.
\left. +
\left(\ds\frac{-1}{2}\right)\left(\ds\frac{-3}{2}\right)+\cdots\right.$

$\left.+\left(\ds\frac{-[2n+1]}{2}\right)\ds\frac{1}{x^{2n+1}}\right]$

$+\left(\ds\frac{-1}{2}\right)\left(\ds\frac{-3}{2}\right)+\cdots
+ \left(\ds\frac{-[2n-1]}{2}\right)(-[2n+1]) \times
\ds\int_x^\infty\ds\frac{1}{t^{2n+1}}te^{-t^2}\, dt$

$ =  \ds\frac{e^{-x^2}}{\sqrt{\pi}}\sum_{r=0}^{n}
\frac{(-1)^r\Gamma(r+\frac{1}{2})}{x^{2r+1}} \ {\rm
(\star)}+R_n(x)$

(using result given on $\Gamma$ functions.)

$ R_n(x)  =
-\ds\frac{\Gamma(n+\frac{1}{2})(2n+1)}{\sqrt{\pi}}(-1)^n\ds\int_x^{\infty}
\ds\frac{e^{-t^2}}{t^{2n+2}}\, dt $




\item[(iii)]

Consider

$\begin{array}{rcl} |R_n(x)| & = &
\ds\frac{\Gamma(n+\frac{1}{2})(2n+1)}{\sqrt{\pi}}
\left|\ds\int_x^\infty \ds\frac{e^{-t^2}}{t^{2n+2}}\, dt \right|\\
& & \left(\Gamma\left(n+\frac{1}{2}\right)>0\  {\rm for\ }
n>0\right)\\ & \leq &
\ds\frac{\Gamma(n+\frac{1}{2})}{\sqrt{\pi}}(2m+1)\ds\int_x^\infty\left|\ds\frac{e^{-t^2}}{t^{2n+2}}\right|\,dt
\end{array}$

${}$

For $x>0$\ \
$\left|\ds\frac{e^{-t^2}}{t^{2n+2}}\right|=\ds\frac{e^{-t^2}}{t^{2n+2}}$

${}$

Now $\ds\frac{e^{-t^2}}{t^{2n+2}}=\ds\frac{1}{t^{2n+3}}te^{-t^2}
\leq \ds\frac{te^{-t^2}}{x^{2n+3}}$ for \un{$t>x\ (>0)$}

\begin{eqnarray*} {\rm Therefore\ \ } |R_n(x)| & \leq &
\ds\frac{\Gamma(n+\frac{1}{2})(2n+1)}{\sqrt{\pi}}\ds\int_x^\infty\ds\frac{te^{-t^2}}{x^{2n+3}}\,
dt\\ \Rightarrow |R_n(x)|  &\leq&
\ds\frac{\Gamma(n+\frac{1}{2})(2n+1)}{x^{2n+3}\sqrt{\pi}}\ds\int_x^\infty
te^{-t^2}\, dt \end{eqnarray*}

\item[(iv)]
From this result

$$|R_n(x)| \leq
\ds\frac{\Gamma(n+\frac{1}{2})(2n+1)}{x^{2n+3}\sqrt{\pi}}\ds\frac{e^{-x^2}}{2}$$

This is then

$$R_n(x)=O\left(\ds\frac{e^{-x^2}}{x^{2n+3}}\right)$$

which is of the order of the first neglected term in the series
($\star$) above, as $x\to+\infty$.

Hence the series ($\star$) is Poincar\'e asymptotic as
$x\to+\infty$.

Therefore $\sqrt{\pi}(1-{\rm erf}(x))\sim
\ds\frac{e^{-x^2}}{\sqrt{pi}}\sum_{r=0}^\infty
\ds\frac{(-1)^r\Gamma(r+\frac{1}{2})}{x^{2r+1}},\ x\to+\infty$

or ${\rm
erf}(x)\sim1-\ds\frac{e^{-x^2}}{\pi}\sum_{r=0}{\infty\ds\frac{(-1)^r\Gamma
(r+\frac{1}{2})}x^{2r+1}},\ x\to+\infty$

\item[(v)]
Let truncation $=n$

$|$Relative \% error$|$ $=
\left|1-\ds\frac{\rm{approx}}{\rm{exact}}\right|\times 100$

\bigskip

\hspace{.1in}$n$\hspace{.5in} approx\hspace{.8in} $|$rel. \%
err$|$

$\left.\begin{array}{lll} 0\hspace{.4in}&0.99_{\uparrow}
4833257\hspace{.4in}&0.0491\\ 1&0.995_{\uparrow}479079&0.158\\
2&0.995_{\uparrow} 2369057&0.0086\\ 3&0.9953_{\uparrow}
882752&0.0066
\end{array}\right\}$ Error decreases

(Best approximation for $x=2$ is when $n=3$.)

$\left.\begin{array}{lll}
4\hspace{.4in}&0.9952558269\hspace{.4in}&0.0067\\
5&0.9954048313&0.0083\\6&0.9951999503&0.0123\\
7&0.9955328819&0.0212\\8&0.9949086351&0.0416\\
9&0.9962351596&0.0917\\10&0.9930846639&0.225\\ \vdots&&
\end{array}\right\}$ Error increases

\hspace{.1in}20\hspace{.4in} 0.9953222950189\hspace{.2in}
120,000\% error!

EXACT\hspace{.1in} 0.9953222650189\hspace{.3in} 0


THE SERIES IS DIVERGENT! (for all $x$) (via e.g., ratio test), but
excellent agreement initially. This can be explained by looking at
the size of the terms
$\ds\frac{\Gamma\left(r+\frac{1}{2}\right)}{2^{2r}}$ for
$r=0\cdots$.

\bigskip

\begin{center}
\hspace{.1in}$r$\hspace{.7in}$\ds\left|\frac{\Gamma\left(r+\frac{1}{2}\right)}{2^{2r}}\right|$

$\left.\begin{array}{ll} 0\hspace{.7in}&1.772\\ 1&0.222\\
2&0.083\\ 3&0.052\\4&0.045
\end{array}\right\}$
\begin{tabular}{l}Terms\\ decrease\\ in size \end{tabular}

$\left.\begin{array}{ll} 5\hspace{.7in}&0.051\\ 5&0.070\\
7&0.114\\ 8&0.214 \end{array}\right\}$
\begin{tabular}{l}Terms\\ increase\\ in size \end{tabular}
\end{center}


As $|R_n|=0$ (1st neglected term) we see $|R_n|$ decreases to a
minimum at $n \approx 4$ before increasing indefinitely.
\end{description}

\end{document}
