# Definite integral involving an error function

Let $$\mathrm{erf}(x) = \frac{2}{\sqrt{\pi}}\int\limits_{0}^x e^{-t^2}dt$$ be the error function. Then, I have tow questions.

1. For a positive integer $n$, is there a close-form solution of $f_n=\int_{0}^\infty 1- (\mathrm{erf}(x))^n dx$?

2. Is there a positive $c<\infty$ such that $\lim\limits_{n\to\infty}\frac{f_n}{\sqrt{\log n}} =c$.

Mathematica returns $1/\sqrt{\pi}$ when $n=1$ and $\sqrt{2/\pi}$ when $n=2$.

• – user37238 Mar 3 '16 at 14:37
• I figured out the derivation of $n=3$ but it is messy as heck. I will try to find time over the next few days to illustrate. – Ron Gordon Mar 4 '16 at 12:48

Let $\Delta^{n}$ be a portion of the unit $n$-sphere $S^n$ defined by

$$\Delta^n = \{ \omega \in S^n : 0 < \omega_1 < \cdots < \omega_n < \tfrac{1}{\sqrt{2}} \omega_{n+1} \}. \tag{1}$$

Then it is not hard to check that for $n \geq 2$,

$$f_n = 2^{n-\frac{5}{2}} \pi^{-n/2} n! \left( \tfrac{n-3}{2} \right)! \operatorname{Vol}(\Delta^{n-2}).$$

(Here, we use the convention that $\Delta^0$ is a single point and thus $\operatorname{Vol}(\Delta^0) = 1$.) This allows to compute $f_n$ for certain $n$'s:

1. When $n = 2$, we immediately have $$f_2 = \sqrt{\frac{2}{\pi}}.$$

2. When $n = 3$, then $\Delta^1$ is a portion of the unit circle with arc length $\arctan(1/\sqrt{2})$. So we have $$f_3 = \frac{6\sqrt{2}}{\pi^{3/2}} \arctan(1/\sqrt{2}).$$

3. When $n = 4$, it is not hard to check that $\Delta^2$ is a spherical triangle with angles $\frac{\pi}{4}$, $\frac{\pi}{2}$ and $\arctan \sqrt{2}$. Consequently the area of $\Delta^2$ is $\frac{\pi}{4} - \arctan(1/\sqrt{2})$, which is equal to $\frac{1}{2}\arctan(1/\sqrt{8})$. So we have $$f_4 = \frac{12\sqrt{2}}{\pi^{3/2}} \arctan(1/\sqrt{8}).$$

I am not sure about $n =5$, but it probably requires some well-established theory on orthoschemes to compute the volume of $\Delta^3$. So I will stop here.

Instead, let us investiguate the asymptotic behavior of $f_n$.

Intuition. Let $X_1, X_2, \cdots$ be i.i.d. such that the common CDF $F_X$ is given by $\mathrm{erf}$. (In particular, $X_i$ are a.s. non-negative.) Let $M_n = \max\{X_1, \cdots, X_n\}$. Then

$$\Bbb{P}(M_n > x) = 1 - \Bbb{P}(M_n \leq x) = 1 - F_X(x)^n = 1 - \operatorname{erf}(x)^n.$$

Consequently we have

$$f_n = \int_{0}^{\infty} (1 - \operatorname{erf}(x)^n) \, dx = \Bbb{E}M_n.$$

In general, $M_n$ has roughly the same asymptotics as the last $n$-quantile of the distribution of $X$. In other words, if $x_n$ is chosen so that $F_X(x_n) = 1 - n^{-1}$ then $M_n$ and $x_n$ has roughly the same order. But in our case, it is not hard to show that $x_n \sim (\log n)^{1/2}$. Thus we expect that $f_n \sim (\log n)^{1/2}$.

Solution. Apply the substitution $x \mapsto x \sqrt{\log n}$ to write

$$\frac{f_n}{\sqrt{\log n}} = \int_{0}^{\infty} (1 - \operatorname{erf}(x \sqrt{\log n})^n ) \, dx.$$

In order to facilitate this identity, we first make the following simple observation:

Lemma. We have $\operatorname{erf}(x) = 1 - \frac{1 + o(1)}{x\sqrt{\pi}} e^{-x^2}$ as $x \to \infty$.

Indeed, this is a direct consequence of the L'Hospital's rule. Now fix any $R > 1$. By the lemma, there exists a sufficiently large $N = N(R)$ such that for $x \geq R$ and $n \geq N$ we have a uniform estimate

$$1 - \operatorname{erf}(x \sqrt{\log n})^n \leq n \operatorname{erf}(x \sqrt{\log n}) \leq \frac{C}{x \sqrt{\log n}} n^{1-x^2} \leq \frac{C}{x\sqrt{\log n}} N^{1 - x^2}$$

for some constant $C = C(R) > 0$. Thus it follows that

$$0 \leq \int_{R}^{\infty} (1 - \operatorname{erf}(x \sqrt{\log n})^n) \, dx \leq \frac{C}{\sqrt{\log n}} \int_{R}^{\infty} \frac{N^{1 - x^2}}{x} \, dx \xrightarrow{n\to\infty} 0.$$

On the other hand, for any fixed $x > 0$ we have

$$\operatorname{erf}(x \sqrt{\log n})^n = \left(1 - \frac{1+o(1)}{x\sqrt{\pi \log n}} n^{-x^2} \right)^n \xrightarrow{n\to\infty} \begin{cases} 0, & x < 1 \\ 1, & x \geq 1. \end{cases}$$

Thus by the bounded convergence theorem, we have

$$\int_{0}^{R} (1 - \operatorname{erf}(x \sqrt{\log n})^n) \, dx \xrightarrow{n\to\infty} 1.$$

Therefore we have

$$\lim_{n\to\infty} \frac{f_n}{\sqrt{\log n}} = 1.$$

Here is a partial answer: For $n=3$ and $n=4$, closed-form solutions exist, according to Ng and Geller (A Table of Integrals of the Error Function. II. Additions and Corrections, Journal of Research of the National Bureau of Standards, Vol. 75B, 1971, pp. 149-163; see $\S3.7$, Eqs. 21 and 22, p. 158), $$f_3={6\over\pi}\sqrt{2\over\pi}\tan^{-1}(2^{-1/2})$$ and $$f_4={12\over\pi}\sqrt{2\over\pi}\tan^{-1}(8^{-1/2})\,.$$ I verified Ng and Geller's expressions via Mathematica's numerical integration routine, NIntegrate. I don't quite see the derivation yet, but I'll try to generalize to other values of $n$.

To provide motivation for what follows, let's begin with the $n=1$ case.

## $$n=1$$

Here we wish to evaluate

$$I_1 = \int_0^{\infty} dx\, \left (1-\operatorname{erf}{x} \right )$$

where

$$\operatorname{erf}{x} = \frac{2}{\sqrt{\pi}} \int_0^x dt \, e^{-t^2} = \frac{2}{\sqrt{\pi}} x \int_0^1 dt \, e^{-x^2 t^2}$$

Note also that

$$\int_0^{\infty} dt \, e^{-x^2 t^2} = \frac{\sqrt{\pi}}{2 x} \implies 1 = \frac{2}{\sqrt{\pi}} x \int_0^{\infty} dt \, e^{-x^2 t^2}$$

Thus

$$1-\operatorname{erf}{x} = \frac{2}{\sqrt{\pi}} x \left [ \int_0^{\infty} dt \, e^{-x^2 t^2} - \int_0^1 dt \, e^{-x^2 t^2}\right ] = \frac{2}{\sqrt{\pi}} x \int_1^{\infty} dt \, e^{-x^2 t^2}$$

Yes, I know I took a lot of extra steps to derive something that could be presented in one step. But I need this so the next cases do not seem out of left field. Anyway, the integral in this case is readily derived by changing the order of integration:

\begin{align}I_1 &= \frac{2}{\sqrt{\pi}} \int_1^{\infty} dt \, \int_0^{\infty} dx\, x \, e^{-x^2 t^2}\\ &= \frac{1}{\sqrt{\pi}} \int_1^{\infty} dt \frac1{t^2} \\ &= \frac{1}{\sqrt{\pi}} \end{align}

OK, I hope that was straightforward.

## $$n=2$$

Now let's step things up a bit and evaluate

$$I_2 = \int_0^{\infty} dx\, \left (1-\operatorname{erf}^2{x} \right )$$

Here, we observe that

$$\operatorname{erf}^2{x} = \frac{4}{\pi} x^2 \int_0^1 dt_1 \, \int_0^1 dt_2 \, e^{-x^2 (t_1^2+t_2^2)}$$

However, in an analogous result as above, note that

$$1 = \frac{4}{\pi} x^2 \int_0^{\infty} dt_1 \, \int_0^{\infty} dt_2 \, e^{-x^2 (t_1^2+t_2^2)}$$

so that

$$1-\operatorname{erf}^2{x} = \frac{4}{\pi} x^2 \left [ \int_0^{\infty} dt_1 \, \int_0^{\infty} dt_2 \, e^{-x^2 (t_1^2+t_2^2)} - \int_0^{1} dt_1 \, \int_0^{1} dt_2 \, e^{-x^2 (t_1^2+t_2^2)} \right ]$$

I hope the reader appreciates why I set up the $n=1$ case as I had done. Now we have a different sort of complementary region: a small square cut out of a larger one. Drawing this out, one sees that there are three integration regions: $[0,1] \times [1,\infty)$, $[1,\infty) \times [0,1]$, and $[1,\infty) \times [1,\infty)$. It should be appreciated that the first two regions will result in the same integral by symmetry. Thus,

$$1-\operatorname{erf}^2{x} = \frac{4}{\pi} x^2 \left [ 2 \int_1^{\infty} dt_1 \, \int_0^{1} dt_2 \, e^{-x^2 (t_1^2+t_2^2)} + \int_1^{\infty} dt_1 \, \int_1^{\infty} dt_2 \, e^{-x^2 (t_1^2+t_2^2)} \right ]$$

Thus,

\begin{align} I_2 &= \frac{4}{\pi} \left [ 2 \int_1^{\infty} dt_1 \, \int_0^{1} dt_2 \, + \int_1^{\infty} dt_1 \, \int_1^{\infty} dt_2 \, \right ] \int_0^{\infty} dx \, x^2 \, e^{-x^2 (t_1^2+t_2^2)} \\ &= \frac1{\sqrt{\pi}} \left [ 2 \int_1^{\infty} dt_1 \, \int_0^{1} dt_2 \, (t_1^2+t_2^2)^{-3/2} + \int_1^{\infty} dt_1 \, \int_1^{\infty} dt_2 \, (t_1^2+t_2^2)^{-3/2} \right ]\\ &=\frac1{\sqrt{\pi}} \left [ \int_1^{\infty} dt_1 \, \int_0^{1} dt_2 \, (t_1^2+t_2^2)^{-3/2} + \int_1^{\infty} dt_1 \, \int_0^{\infty} dt_2 \, (t_1^2+t_2^2)^{-3/2} \right ] \\ &= \frac1{\sqrt{\pi}} \left [ \int_1^{\infty} dt_1 \, \frac1{t_1^2} \, \int_0^{\arctan{(1/t_1)}} d\theta \, \cos{\theta} + \int_1^{\infty} dt_1 \, \frac1{t_1^2} \,\int_0^{\pi/2} d\theta \, \cos{\theta} \right ] \\ &= \frac1{\sqrt{\pi}} \left (1+ \int_1^{\infty} \frac{dt_1}{t_1^2 \sqrt{1+t_1^2}} \right ) \\ &= \frac1{\sqrt{\pi}} \left (1+ \int_{\pi/4}^{\pi/2} d\theta \frac{\cos{\theta}}{\sin^2{\theta}} \right ) \\ &=\frac1{\sqrt{\pi}} \left ( 1 + \sqrt{2} - 1 \right ) \end{align}

Thus,

$$I_2 = \sqrt{\frac{2}{\pi}}$$

## $$n=3$$

$$I_3 = \int_0^{\infty} dx\, \left (1-\operatorname{erf}^3{x} \right )$$

Now, let's apply similar reasoning to the case $n=3$. Yes, this involves triple integrals and is messy.

\begin{align}1-\operatorname{erf}^3{x} &= \frac{8}{\pi^{3/2}} x^3 \times \\ & \left [ \int_0^{\infty} dt_1 \, \int_0^{\infty} dt_2 \, \int_0^{\infty} dt_3 \, e^{-x^2 (t_1^2+t_2^2+t_3^2)} - \int_0^{1} dt_1 \, \int_0^{1} dt_2 \, \int_0^{1} dt_3 \, e^{-x^2 (t_1^2+t_2^2+t_3^2)} \right ]\end{align}

Now we have a three-dimensional space missing a small cube in one corner. The result is seven different regions, 3 of which are $[1,\infty) \times [0,1] \times [0,1]$, 3 of which are $[1,\infty) \times [1,\infty) \times [0,1]$, and one being $[1,\infty) \times [1,\infty) \times [1,\infty)$. I hope you are sensing the beginning of a pattern:

\begin{align}1-\operatorname{erf}^3{x} &= \frac{8}{\pi^{3/2}} x^3 \times \\ & \left [3 \int_1^{\infty} dt_1 \, \int_0^{1} dt_2 \, \int_0^{1} dt_3 \, e^{-x^2 (t_1^2+t_2^2+t_3^2)} + 3 \int_1^{\infty} dt_1 \, \int_1^{\infty} dt_2 \, \int_0^{1} dt_3 \, e^{-x^2 (t_1^2+t_2^2+t_3^2)} \\ + \int_1^{\infty} dt_1 \, \int_1^{\infty} dt_2 \, \int_1^{\infty} dt_3 \, e^{-x^2 (t_1^2+t_2^2+t_3^2)}\right ]\end{align}

Thus, switching the order of integration

\begin{align}I_3 &= \frac{8}{\pi^{3/2}} \left [3 \int_1^{\infty} dt_1 \, \int_0^{1} dt_2 \, \int_0^{1} dt_3 \, + 3 \int_1^{\infty} dt_1 \, \int_1^{\infty} dt_2 \, \int_0^{1} dt_3 \, + \int_1^{\infty} dt_1 \, \int_1^{\infty} dt_2 \, \int_1^{\infty} dt_3 \, \right ]\times \int_0^{\infty} dx \, x^3 \, e^{-x^2 (t_1^2+t_2^2+t_3^2)}\\ &= \frac{4}{\pi^{3/2}} \left [3 \int_1^{\infty} dt_1 \, \int_0^{1} dt_2 \, \int_0^{1} \frac{dt_3}{(t_1^2+t_2^2+t_3^2)^{2}} \, + 3 \int_1^{\infty} dt_1 \, \int_1^{\infty} dt_2 \, \int_0^{1} \frac{dt_3}{(t_1^2+t_2^2+t_3^2)^{2}} \, + \int_1^{\infty} dt_1 \, \int_1^{\infty} dt_2 \, \int_1^{\infty} \frac{dt_3}{(t_1^2+t_2^2+t_3^2)^{2}} \, \right ] \end{align}

The evaluation of these integrals by hand was a time-consuming exercise that I recommend doing by hand once in your life just to know how much organization and attention to detail it requires. I did that and will outline below how I did the third one. However, it should be kept in mind that Mathematica returns the correct value of these integrals. (This should be seen as a minor victory in and of itself, as Mathematica certainly could not do the original integral.)

So let's consider

$$\int_1^{\infty} \frac{dt_3}{(t_1^2+t_2^2+t_3^2)^{2}}$$

Sub $t_3 = \sqrt{t_1^2+t_2^2} \tan{\theta}$; then the integral is equal to

$$\frac1{(t_1^2+t_2^2)^{3/2}} \int_{\arctan{1/\sqrt{t_1^2+t_2^2}}}^{\pi/2} d\theta\, \cos^2{\theta} \\ = \frac12 \frac1{(t_1^2+t_2^2)^{3/2}} \left [\arctan{\left (\sqrt{t_1^2+t_2^2} \right )} - \frac{\sqrt{t_1^2+t_2^2}}{1+t_1^2+t_2^2} \right ]$$

Now let's do the integration over $t_2$:

\begin{align}\int_1^{\infty} dt_2 \, \int_1^{\infty} \frac{dt_3}{(t_1^2+t_2^2+t_3^2)^{2}} &= \frac12 \int_1^{\infty} dt_2 \, \frac1{(t_1^2+t_2^2)^{3/2}} \left [\arctan{\left (\sqrt{t_1^2+t_2^2} \right )} - \frac{\sqrt{t_1^2+t_2^2}}{1+t_1^2+t_2^2} \right ]\\ &= \frac1{2 t_1^2} \int_{\arctan{1/t_1}}^{\pi/2} d\theta \, \cos{\theta} \left [\tan{\left (\frac{t_1}{\cos{\theta}} \right )} - \frac{t_1 \cos{\theta}}{t_1^2+\cos^2{\theta}}\right ] \end{align}

We integrate by parts and the integral is equal to

$$\frac1{2 t_1^2} \left [\sin{\theta} \arctan{\left (\frac{t_1}{\cos{\theta}} \right )} \right ]_{\arctan{1/t_1}}^{\pi/2} - \frac1{2 t_1^2} \int_{\arctan{1/t_1}}^{\pi/2} d\theta \, \frac{\sin{\theta}}{1+\frac{t_1^2}{\cos^2{\theta}}} \frac{t_1 \sin{\theta}}{\cos^2{\theta}} \\ - \frac1{2 t_1^2} \int_{\arctan{1/t_1}}^{\pi/2} d\theta \, \frac{t_1 \cos^2{\theta}}{t_1^2+\cos^2{\theta}}$$

or

$$\frac1{2 t_1^2} \left [\frac{\pi}{2} - \frac1{\sqrt{1+t_1^2}} \arctan{\sqrt{1+t_1^2}} \right ] - \frac1{2 t_1} \int_{\arctan{1/t_1}}^{\pi/2} \frac{d\theta}{t_1^2+\cos^2{\theta}}$$

The integral on the RHS may be done by writing $\cos^2{\theta} = 1 - \sin^2{\theta}$, performing a partial fractions decomposition, and then using a Weierstrass substitution $u = \tan{(\theta/2)}$. I assure the reader I did this by hand and leave the evaluation of the integral as an exercise. The result is

$$\int \frac{d\theta}{t_1^2+\cos^2{\theta}} = \frac1{t_1 \sqrt{1+t_1^2}} \arctan{ \left (\frac{t_1 \tan{\theta}}{\sqrt{1+t_1^2}} \right )}+C$$

The result is that the integral over $t_2$ is equal to

$$\frac{\pi}{4 t_1^2} \left (1-\frac1{\sqrt{1+t_1^2}} \right ) - \frac1{2 t_1^2 \sqrt{1+t_1^2}} \left (\arctan{\sqrt{1+t_1^2}} - \arctan{\frac1{\sqrt{1+t_1^2}}} \right )$$

Finally, we integrate over $t_1$. The manipulations at this point will look pretty familiar (i.e., trig substitution and integration by parts), so I will spare the reader the details which I assure I have done out completely by hand. The result is

$$\int_1^{\infty} dt_1 \, \int_1^{\infty} dt_2 \, \int_1^{\infty} \frac{dt_3}{(t_1^2+t_2^2+t_3^2)^{2}} = \frac{3}{\sqrt{2}} \arctan{\frac1{\sqrt{2}}} - 3 \left ( \sqrt{2}-1 \right ) \frac{\pi}{4}$$

We of course have two other integrals to evaluate. At this point, I will further spare the reader and just write the results out:

$$\int_1^{\infty} dt_1 \, \int_1^{\infty} dt_2 \, \int_0^1 \frac{dt_3}{(t_1^2+t_2^2+t_3^2)^{2}} = \left (2 \sqrt{2} - 1 \right ) \frac{\pi}{4} - \frac{3}{\sqrt{2}} \arctan{\frac1{\sqrt{2}}}$$

$$\int_1^{\infty} dt_1 \, \int_0^1 dt_2 \, \int_0^1 \frac{dt_3}{(t_1^2+t_2^2+t_3^2)^{2}} = \frac{3}{\sqrt{2}} \arctan{\frac1{\sqrt{2}}} - \sqrt{2} \frac{\pi}{4}$$

Finally, we can now simply write the value of the original integral as

$$I_3 = \frac{6}{\pi} \sqrt{\frac{2}{\pi}} \arctan{\frac1{\sqrt{2}}}$$

For arbitrary $n$, I hope it is clear how one may go about the evaluation of the integral:

$$\int_0^{\infty} dx \, \left (1-\operatorname{erf}^n{x} \right ) = \\\frac12 \Gamma \left (\frac{n+1}{2} \right ) \left (\frac{2}{\sqrt{\pi}} \right )^n \sum_{k=1}^n \binom{n}{k} \int_1^{\infty} dt_1 \, \cdots \int_1^{\infty} dt_k \, \int_0^1 dt_{k+1} \, \cdots \int_0^1 dt_n \left (t_1^2+\cdots t_n^2 \right )^{-(n+1)/2}$$

I will leave it here at this point.