Closed form for the similar integrals $\int_0^\infty1-\text{erf}(x)dx$ and $\int_0^\infty x(1-\text{erf}(x))dx$

calculuserror functionintegration

How do I find a closed form of $$\int_0^\infty1-\text{erf}(x)dx\tag{1}$$? A follow up is $$\int_0^\infty x(1-\text{erf}(x))dx\tag{2}$$Where $$\text{erf}(x)=\frac2{\sqrt{\pi}}\int_0^xe^{-t^2}dt$$The second integral seems to be $\frac14$ according to desmos. I also found that the first integral is $\frac1{\sqrt{\pi}}$. I have solved these integrals (I will post them in an answer) but I wonder if there are other solutions.

Best Answer

Note that the function $t \mapsto \frac{2}{\sqrt{\pi}}e^{-t^2}$ is nothing but the density of random variable $Y=|X|$, where $X$ has $\mathcal N(0,\frac{1}{2})$ distribution (i.e. gaussian/normal with mean $0$ and variance $\frac{1}{2}$).

Then, $1-\text{erf}(x)$ is nothing but $\mathbb P(|X| > x)$.

Moreover, we have a formula for $p'$th absolute moment in terms of CDF, i.e. $$ \mathbb E|X|^p = \int_0^\infty pt^{p-1} \mathbb P(|X|>t)dt.$$

Hence, $$ \int_0^\infty (1-\text{erf}(x))dx = \int_0^\infty \mathbb P(|X|>x)dx = \mathbb E|X| = \frac{1}{\sqrt{2}} \mathbb E|\mathcal N(0,1)| = \frac{1}{\sqrt{\pi}}$$ and $$ \int_0^\infty x(1-\text{erf}(x))dx = \frac{1}{2} \int_0^\infty 2x^{2-1}\mathbb P(|X|>x)dx = \frac{1}{2} \mathbb E|X|^2 = \frac{1}{4}.$$

More generally, given any $p>0$ you have $$ \int_0^\infty x^p (1-\text{erf}(x))dx = \frac{1}{p+1} \int_0^\infty(p+1) x^{p+1 - 1}\mathbb P(|X|>x)dx $$ $$ = \frac{1}{p+1} \mathbb E|X|^{p+1} = \frac{\mathbb E|\mathcal N(0,1)|^{p+1}}{(p+1) 2^{\frac{p+1}{2}}} = \frac{1}{\sqrt{\pi}(p+1)} \Gamma\left(\frac{p}{2}+1\right) = \frac{p\Gamma\left(\frac{p}{2}\right)}{2(p+1)\sqrt{\pi}},$$ where $$\Gamma(a) = \int_0^\infty x^{a-1}e^{-x}dx, \quad a>0$$ is the Euler-Gamma function.

Related Question