TITLE: Steps in evaluating the integral of complementary error function?
QUESTION [6 upvotes]: Could you please check the below and show me any errors?
$$ \int_ x^ \infty {\rm erfc} ~(t) ~dt ~=\int_ x^ \infty \left[\frac{2}{\sqrt\pi} \int_ t^ \infty e^{-u^2} du \right]\ dt $$
If I let dv=dt and u equal the term inside the bracket, and do integration by parts, 
$$ \int u ~dv ~=uv - \int v~ du $$
v=t and du becomes 
$$ -\frac{2}{\sqrt\pi} e^{-t^2} $$
This was obtained from using the Leibniz rule below, 
$$ \frac {d} {dt} \left[ \int_ a^ b f(u)du \right]\ =  \int_ a^ b \frac {d} {dt} f(u) du + f \frac {db} {dt} - f \frac {da} {dt} $$
Then,
$$ \frac {d} {dt} \left[\frac{2}{\sqrt\pi} \int_ t^ \infty e^{-u^2} du \right]\ = \frac{2}{\sqrt\pi} \left[ \int_ t^ \infty \frac {d} {dt} \left( e^{-u^2} \right) du + e^{-\infty ^2} * 0 - e^{-t^2}*1 \right]= \frac{2}{\sqrt\pi} \left[0~+~0~-  e^{-t^2} \right]$$
Is the first and second term going to zero correct?  The upper limit b=infinity, and is db/dt=0 in the second term correct?
The integral becomes
$$ \left[~ t~ \frac{2}{\sqrt\pi} \int_ t^ \infty e^{-u^2} du ~\right] _{x}^\infty + \int_ x^ \infty t \left[\frac{2}{\sqrt\pi} e^{-t^2}  \right]\ dt =$$
$$ \left[~ t~ \frac{2}{\sqrt\pi} \int_ t^ \infty e^{-u^2} du ~\right] _{x}^\infty - \left[\frac{1}{\sqrt\pi} e^{-t^2}  \right] _{x}^\infty   =$$
$$ \left[ 0 - ~ x~ \frac{2}{\sqrt\pi} \int_ x^ \infty e^{-u^2} du ~\right] - \left[ 0 - \frac{1}{\sqrt\pi} e^{-x^2} \right] = $$
(Is the first limit going to zero OK?  infinity times 0 = 0). The above becomes
$$ -x~ {\rm erfc}~(x) + \frac{1}{\sqrt\pi} e^{-x^2} $$
Is everything correct here? Could you please give explanation to the questions I listed?

REPLY [6 votes]: You can also achieve this result by an interchange of the integrals as follows.
$$
\int_x^\infty {\rm erfc}(t)\,dt = {2\over\sqrt{\pi}}\int_x^\infty\left(\int_t^\infty e^{-u^2}\,du\right)dt = \iint_{x<t<u} e^{-u^2}\,dudt.
$$
Now interchange the order of integration to get
$$
\int_x^\infty {\rm erfc}(t)\,dt ={2\over\sqrt{\pi}}\int_x^\infty\left( \int_x^udt\right)
e^{-u^2}\,du = {2\over\sqrt{\pi}}\int_x^\infty (u-x)e^{-u^2}\,du,
$$
hence
$$
\int_x^\infty {\rm erfc}(t)\,dt= {1\over{\sqrt{\pi}}}e^{-x^2} - x{\rm erfc}(x). $$