During my research I came across this integral

$$\int_0^\infty\operatorname{erf}^2(x)e^{-(x+b)^2}dx $$

I’ve looked through two collections on integrals of the error function (for instance, Korotkov's Table of Integrals Related to the Error Function (PDF link via ucr.edu)), and have tried a few steps of integration by parts, but things seemed to only get worse. Substitution does not help much, either.

If the integral ultimately cannot be solved that’s ok for now, though anyone want to take a stab at it?

  • 2
    $\begingroup$ You may try substituting by means of $$ \operatorname{erf}^2 (x) = 1 - \frac{4}{\pi }\int_0^1 {\frac{{e^{ - x^2 (t^2 + 1)} }}{{t^2 + 1}}dt} $$ (dlmf.nist.gov/7.7.E5) and interchange the order of integration. $\endgroup$
    – Gary
    Commented Oct 22, 2020 at 6:39
  • $\begingroup$ This seems much easier than the way I did it. Is the integral possible using this technique? Do we get a function for $b$? Not sure if you actually evaluted it and know it works, or if you just suggested a method. Cheers. @Gary $\endgroup$
    – user817934
    Commented Oct 22, 2020 at 7:58
  • $\begingroup$ @Cjw123 It was just a suggestion, I did not do the calculations. $\endgroup$
    – Gary
    Commented Oct 22, 2020 at 7:59
  • $\begingroup$ @Gary If you use this method, you get a bunch of values in terms of b, but you end up with $\int_{0}^{1} \frac{e^{t^2}}{1+t^2}$. Any idea on how to tackle this, or does it not have a closed form? If it doesn't, I may resort to my method below.... $\endgroup$
    – user817934
    Commented Oct 22, 2020 at 11:00
  • $\begingroup$ @Cjw123 I do not belive there is a closed form for that integral in terms of known things. Anyhow, I tried this approach myself and ended up with a complicated integral involving $\operatorname{erfc}$. Perhaps I made a mistake somewhere? $\endgroup$
    – Gary
    Commented Oct 22, 2020 at 11:20

1 Answer 1


We will use the fact that: $\mathrm{erf} (x) = \frac{2}{\sqrt{\pi}} \int_{0}^{x} e^{-t^{2}} dt$.

Thus, $$\mathrm{erf}^{2} (x) = \frac{4}{\pi} \int_{0}^{x} \int_{0}^{x} e^{-y^2+z^2}dydz.$$

Replace this expression into the integral you have, and you'll end up with:

$$ \int_{0}^{\infty}\mathrm{erf}^2(x)e^{-(x+b)^2}dx = \frac{4}{\pi}\int_{0}^{\infty}\int_{0}^{x}\int_{0}^{x} e^{-((x+b)^2+y^2+z^2)} dzdydx$$

We'll ignore the $\frac{4}{\pi}$ for now, and just attack the integral. This is a candidate for spherical coordinates. However, this region gets VERY hard to turn into spherical coordinates once you involve the $b$ in the equation. Keep in mind we have to use, instead of the traditional $(x,y,z) = ( \rho \cos \theta \sin\phi, \rho \sin\theta \sin\phi, \rho \cos \phi)$, we have accounted for the $(x+b)$ by using $(x + b,y,z) = ( \rho \cos \theta \sin \phi, \rho \sin \theta \sin \phi, \rho \cos \phi)$. This overall does not change the Jacobian value of $\rho ^2 \sin \phi$, as the $x$ term becomes $\rho \cos \theta \sin \phi - b$, which under all partials, the $-b$ goes to $0$. HOWEVER, the region you're bounding now becomes very complicated. The region that this triple integral encloses is simple enough for $\rho$ and $\theta$. However, because the solid is bound by the plane $z = x + y$, we need to make our $\phi$ value $0 \leq \phi \leq z = x + y$. Replacing $z = x + y$ in for spherical coordinates reveals that $\cos \phi = (\sin\theta + \cos\theta) \sin\phi - b.$ To solve for $\phi$, technically, the solution is:

$$\phi = 2(\arctan(\frac{\sqrt{2 - b^2 + 2\cos\theta \sin\theta}}{b - 1}))$$ if $b \neq 1$ and $b \neq (\sin\theta + \cos \theta)\sqrt{2+2\sin\theta \cos\theta} + 2 + 2\sin\theta \cos\theta.$ We are going to assume this is true, because I'm already getting a headache, haha. Nonetheless, this integral will become:

$$\int_{0}^{\infty} \int_{0}^{\frac{\pi}{4}} \int_{0}^{2(\arctan(\frac{\sqrt{2 - b^2 + 2\cos\theta \sin\theta}}{b - 1}))} e^{-\rho ^2} \rho^2 \sin(\phi)d\phi d\theta d\rho.$$

This actually looks worse than it is, because the $\rho$ integral you can take out, as we know its value. $\int_{0}^{\infty} \rho ^2 e^{-\rho ^2} d \rho = \frac{\sqrt{\pi}}{4}.$ Our integral is just in terms of $\phi$ and $\theta.$ Namely:

$$ \frac{\sqrt{\pi}}{4} \int_{0}^{\frac{\pi}{4}} \int_{0}^{2(\arctan(\frac{\sqrt{2 - b^2 + 2\cos\theta \sin\theta}}{b - 1}))} \sin(\phi)d\phi d\theta.$$

This integral actually has an incredibly simple integrand, but it's just the bounds that are confusing. Let's rename $\phi$'s upper bound to $f(\theta)$. Integrating with respect to $\phi$ first, we get:

$$\int_{0}^{\frac{\pi}{4}} [ -\cos(\phi)]_{0,f(\theta)} d\theta = -\int_{0}^{\frac{\pi}{4}} 1 - \cos(f(\theta)) d\theta.$$

Now, this is about where I stop. You can replace $f(\theta)$ with your arctangent business, and take the cosine of the $2 \times$arctangent using some triangles, and I'm sure you will get something nice and neat out of it. I can already see using the double angle formula for cosine being really helpful to cancel square roots. That $\phi$ bound is an absolute headache. Replace what I gave you for $f(\theta)$ and substitute it in, then integrate one more time from $0$ to $\frac{\pi}{4}$ and then multiply by the $\frac{4}{\pi}$ that we got from the start. This integral I'm going to guess is possible by the fact that lots of square roots will cancel, but there's no doubt it will be ugly. This is my solution, and see if you can finish it off and rewrite this ugly mess I got at the end.


EDIT: ONE OF THE BOUNDS IS WRONG ON THE SPHERICAL TRIPLE INTEGRAL. Instead of $0$ to $\phi = 2(\arctan(\frac{\sqrt{2 - b^2 + 2\cos\theta \sin\theta}}{b - 1}))$, you need to use $\phi = 2(\arctan(\frac{\sqrt{2 - b^2 + 2\cos\theta \sin\theta}}{b - 1}))$ to $\frac{\pi}{2}$. Adjust the integral accordingly. Still call this expression $f(\theta)$, but the final integral that I wrote is slightly different. Plug in $f(\theta)$ and $\frac{\pi}{2}$ instead of $0$ and $f(\theta)$.

Edit with proposed solution:

Please double check my work, but this is the solution I found.

Our integral, with the corrected spherical coordinate bounds, and all of the constants put together, becomes:

$$\frac{1}{\sqrt{\pi}} \int_{0}^{\frac{\pi}{4}} f(\theta)d\theta$$

I'm going to rename the variable of integration to $x$, and replace what we decided $f(\theta)$ is, to get the following:

$$\frac{1}{\sqrt{\pi}} \int_{0}^{\frac{\pi}{4}} \mathrm{cos}(2\arctan(\frac{\sqrt{2 - b^2 + 2\cos x \sin x}}{b - 1}))dx.$$

I will leave this for you to verify, but this cosine bit should turn into:

$$\mathrm{cos}(2\arctan(\frac{\sqrt{2 - b^2 + 2\cos x \sin x}}{b - 1})) = \frac{2b^2-2b-1-\sin (2x)}{2b+1+ \sin (2x)}$$

Just using the cosine double angle, and simplifying some fractions. Integrating this from $0$ to $\frac{\pi}{4}$ and then a simple u-substitution, yields:

$$\int_{0}^{\frac{\pi}{4}} \cos (2\arctan(\frac{\sqrt{2 - b^2 + 2\cos x \sin x}}{b - 1})) dx = \int_{0}^{\frac{\pi}{2}} \frac{2b^2-2b-1- \sin (x)}{2b+1+ \sin (x)}dx$$.

We'll use some shorthand, and let $\alpha = 2b^2-2b-1$ and $\beta = 2b+1$. This integral gets messy again, so this will become helpful.

Again, I apologize for this, but the answer to this integral in terms of $\alpha$ and $\beta$ is:


Replace all of this with what we let $\alpha$ and $\beta$ equal to, and you'll get something monstrous, or maybe not! Some of these $\alpha + \beta$ expressions and $\beta ^2 - 1$ expressions may reduce to something nicer. The point is, it's possible. And don't forget to add your $\frac{1}{\sqrt{\pi}}$ out the front. I also understand that we've let some more restrictions on $\beta$, and hence $b$, in addition to the restriction we set on $b$ during the set up of the triple integral that I briefly mentioned, but this is not my place to start figuring out how to mitigate that, or whether it matters, or anything like that, but this is the answer you get from me. My head hurts. The point is: it's possible. Is it nice? Aboslutely not.

Cheers, and I hope this answer is helpful. I recommend you do this by hand, as awful as that sounds, to double-check my integration and logic.

  • $\begingroup$ great answer and well explained complication of "shifted" spherical coordinates, +1 from me $\endgroup$
    – Henry Lee
    Commented Oct 22, 2020 at 19:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .