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

182 Views Asked by At

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.

5

There are 5 best solutions below

1
On BEST ANSWER

For $a>0$, we have

$$ \begin{align} \int_{0}^{\infty} x^{a-1} \left(1-\operatorname{erf}(x) \right) \, \mathrm dx &\overset{(1)}{=} \int_{0}^{\infty} x^{a-1} \, \frac{2}{\sqrt{\pi}}\int_{x}^{\infty} e^{-t^{2}} \, \mathrm dt \, \mathrm dx \\ &\overset{(2)}{=} \frac{2}{\sqrt{\pi}}\int_{0}^{\infty} x^{a} \int_{1}^{\infty} e^{-x^{2}u^{2}} \, \mathrm du \, \mathrm dx \\ &= \frac{2}{\sqrt{\pi}}\int_{1}^{\infty} \int_{0}^{\infty} x^{a}e^{-x^{2}u^{2}} \, \mathrm dx \, \mathrm du \\ &\overset{(3)}{=} \frac{1}{\sqrt{\pi}} \int_{1}^{\infty} \frac{1}{u^{a+1}}\int_{0}^{\infty} w^{a/2-1/2}e^{-w} \, \mathrm dw \, \mathrm du \\ &= \frac{1}{\sqrt{\pi}} \int_{1}^{\infty} \frac{1}{u^{a+1}} \, \Gamma \left(\frac{a}{2} + \frac{1}{2} \right) \, \mathrm du \\ &= \frac{\Gamma \left(\tfrac{a+1}{2}\right)}{a \sqrt{\pi}}. \end{align}$$


$(1)$ $ 1- \operatorname{erf}(x) = \frac{2}{\sqrt{\pi}}\int_{x}^{\infty} e^{-t^{2}} \, \mathrm dt $

$(2)$ Let $u = \frac{t}{x}$.

$(3)$ Let $w= x^{2}u^{2}$.


At $a=1$, we have $$\int_{0}^{\infty} \left(1- \operatorname{erf}(x) \right) \, \mathrm dx = \frac{\Gamma (1)}{\sqrt{\pi}} = \frac{1}{\sqrt{\pi}}. $$

And at $a=2$, we have $$\int_{0}^{\infty} x \left(1- \operatorname{erf}(x) \right) \, \mathrm dx = \frac{\Gamma \left(\frac{3}{2} \right)}{2 \sqrt{\pi}} = \frac{1}{4}.$$


Usually expressing the complementary error function as $$ \frac{2}{\sqrt{\pi}} \int_{1}^{\infty} x e^{-x^{2}u^{2}} \, \mathrm du, \quad x >0, $$ is helpful when evaluating integrals.

But as xpaul pointed out in the comments, it's not necessary here since

$$ \begin{align} \int_{0}^{\infty} x^{a-1} \left(1- \operatorname{erf}(x) \right) \, \mathrm dx &=\int_{0}^{\infty} x^{a-1} \, \frac{2}{\sqrt{\pi}}\int_{x}^{\infty} e^{-t^{2}} \, \mathrm dt \, \mathrm dx \\ &= \frac{2}{\sqrt{\pi}} \int_{0}^{\infty} e^{-t^{2}} \int_{0}^{t} x^{a-1} \, \mathrm dx \, \mathrm dt \\ &= \frac{2}{\sqrt{\pi}} \int_{0}^{\infty} e^{-t^{2}} \, \frac{t^{a}}{a} \, \mathrm dt \\ &= \frac{1}{a \sqrt{\pi}} \int_{0}^{\infty} t^{a/2-1/2} e^{-u} \, \mathrm du \\ &= \frac{1}{a \sqrt{\pi}} \, \Gamma \left(\frac{a+1}{2} \right). \end{align}$$

0
On

For the first integral, we can first find the integral of $\text{erf}(x)$. By IBP: $$\int\text{erf}(x)dx=x\text{erf}(x)-\frac2{\sqrt{\pi}}\int xe^{-x^2}dx=x\text{erf}(x)+\frac{e^{-x^2}}{\sqrt{\pi}}$$So the first integral is instantly solved when substituting it back in and plugging the bounds.

The second integral needs a bit of niftyness. $$I=\int x\text{erf}(x)dx=x^2\text{erf}(x)+\frac{xe^{-x^2}}{\sqrt{\pi}}-\int x\text{erf}(x)+\frac{e^{-x^2}}{\sqrt{\pi}}dx=x^2\text{erf}(x)+\frac{xe^{-x^2}}{\sqrt{\pi}}-\frac{\text{erf}(x)}2-I$$Solving for $I$ then plugging it back into the original integral, we get our answer.

I can kind of understand why the answer of the first integral is $\frac1{\sqrt{\pi}}$, but the second one is just fascinating.

1
On

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.

2
On

Another approach is to employ Feynman's Trick coupled with the Dominated Convergence Theorem and Leibniz' Integral Rule.

Here let: \begin{equation} I = \int_0^\infty \left(1 - \operatorname{erf}\left(x\right) \right)\:dx \end{equation} From here, we introduce all three elements previously mentioned and define the following Integral function: \begin{equation} J\left(t\right) = \int_0^\infty \left(1 - \operatorname{erf}\left(tx\right) \right)\:dx \end{equation} Where $t\geq 0$. We observe that $I = J\left(1\right)$ and furthermore that: \begin{equation} J\left(+\infty\right) = \lim_{t \rightarrow +\infty}J\left(t\right) = \lim_{t \rightarrow +\infty}\int_0^\infty \left(1 - \operatorname{erf}\left(tx\right) \right)\:dx = \int_0^\infty \left(1 - \operatorname{erf}\left(+\infty\right) \right)\:dx = \int_0^\infty \left(1 - 1\right)\:dx = 0 \end{equation} Here we employ Leibniz's Integral Rule and differentiate under the curve w.r.t '$t$': \begin{align} J'\left(t\right) &= \frac{d}{dt} \int_0^\infty \left(1 - \operatorname{erf}\left(tx\right) \right)\:dx = \int_0^\infty \frac{\partial}{\partial t} \bigg(1 - \operatorname{erf}\left(tx\right) \bigg)\:dx = \int_0^\infty -\frac{2}{\sqrt{\pi}}e^{-t^2x^2} \cdot x \:dx \nonumber \\ &=\left[\frac{e^{-t^2x^2}}{t^2\sqrt{\pi}}\right]_0^\infty =-\frac{1}{t^2\sqrt{\pi}} \end{align} And so, \begin{equation} J\left(t\right) =\frac{1}{t\sqrt{\pi}} + C \end{equation} Where $C = $ Constant of Integration. To resolve $C$, we use the condition $J\left(+\infty \right) = 0$ and so, \begin{equation} J\left(+\infty \right) = 0 = 0 + C \rightarrow C = 0 \end{equation} And so: \begin{equation} J\left(t \right) =\int_0^\infty \left(1 - \operatorname{erf}\left(tx\right) \right)\:dx = \frac{1}{t\sqrt{\pi}} \end{equation} And so finally we arrive at our solution for $I$: \begin{equation} I = J\left(1\right) = \int_0^\infty \left(1 - \operatorname{erf}\left(1\cdot x\right) \right)\:dx = \frac{1}{1\cdot\sqrt{\pi}} = \frac{1}{\sqrt{\pi}} \end{equation} Hope this helps.

0
On

After a request from a person's comment, I will apply the same method to a generalised form of the integral:

\begin{equation} H\left(a\right) = \int_0^\infty x^a\left(1 - \operatorname{erf}\left(x\right) \right)\:dx \end{equation} Where $a \in \mathbb{R}$. At this stage, I'm unsure of any required bounds on $a$ (these will be developed as we process the integral).

As with my previous answer, we employ the Dominated Convergence Theorem, Leibniz's Integral Rule, and Feynman's Trick and introduce the function: \begin{equation} J\left(t;a\right) = \int_0^\infty x^a\left(1 - \operatorname{erf}\left(tx\right) \right)\:dx \end{equation} Where $t\geq 0$. We observe that $H\left(a\right) = J\left(1;a\right)$ and furthermore that: \begin{align} J\left(+\infty;a\right) &= \lim_{t \rightarrow +\infty}J\left(t;a\right) = \lim_{t \rightarrow +\infty}\int_0^\infty x^a\left(1 - \operatorname{erf}\left(tx\right) \right)\:dx = \int_0^\infty x^a\left(1 - \operatorname{erf}\left(+\infty\right) \right)\:dx \nonumber \\ & =\int_0^\infty x^a\left(1 - 1\right)\:dx = 0 \end{align} Here we employ Leibniz's Integral Rule and differentiate under the curve w.r.t '$t$': \begin{align} J'\left(t;a\right) &= \frac{\partial}{\partial t} \int_0^\infty x^a\left(1 - \operatorname{erf}\left(tx\right) \right)\:dx = \int_0^\infty x^a\frac{\partial}{\partial t} \bigg(1 - \operatorname{erf}\left(tx\right) \bigg)\:dx = \int_0^\infty x^a \cdot -\frac{2}{\sqrt{\pi}}e^{-t^2x^2} \cdot x \:dx \nonumber \\ &= -\frac{2}{\sqrt{\pi}} \int_0^\infty x^{a + 1}e^{-t^2x^2} \:dx \underset{u = t^2x^2}{=} -\frac{2}{\sqrt{\pi}} \int_0^\infty \left(\frac{\sqrt{u}}{t}\right)^{a + 1}e^{-u} \cdot \frac{1}{2t\sqrt{u}}\:dx \nonumber \\ &= -\frac{1}{t^{a + 2}\sqrt{\pi}} \int_0^\infty u^{\frac{a}{2}} e^{-u}\:du = -\frac{1}{t^{a + 2}\sqrt{\pi}} \Gamma\left(\frac{a}{2} + 1\right) \end{align} Here we observe that $\frac{a}{2} + 1> 0$ or $a > -2$. And so, \begin{equation} J\left(t;a\right) = \frac{1}{\sqrt{\pi}\left(a + 1\right)t^{a + 1}} \Gamma\left(\frac{a}{2} + 1\right) + C \end{equation} Where $C = $ Constant of Integration. Here we observe $a + 1 \neq 0$ or $a \neq -1$. To resolve $C$, we use the condition $J\left(+\infty;a \right) = 0$ and so, \begin{equation} J\left(+\infty;a \right) = 0 = 0 + C \rightarrow C = 0 \end{equation} And so: \begin{equation} J\left(t;a\right) = \frac{1}{\sqrt{\pi}\left(a + 1\right)t^{a + 1}} \Gamma\left(\frac{a}{2} + 1\right) \end{equation}