Differentiation under integral sign

312 Views Asked by At

There is this integral that I used a lot in my research: $$\int_{-\infty}^{\infty}\exp\left(-b^{2}\left(x-c\right)^{2}\right)\mathrm{erf}\left(a\left(x-d\right)\right)\,\mathrm{d}x = \frac{\sqrt{\pi}}{b}\mathrm{erf}\left(\frac{ab\left(c-d\right)}{\sqrt{a^{2}+b^{2}}}\right),$$ for $a,b>0$.

It can be evaluated using the "differentiation under integral sign" method as follows: $$ {\small \begin{aligned} I\left(d\right)&=\int_{-\infty}^{\infty}\exp\left(-b^{2}\left(x-c\right)^{2}\right)\mathrm{erf}\left(a\left(x-d\right)\right)\,\mathrm{d}x\\ \frac{\mathrm{d}}{\mathrm{d}d}I\left(d\right)&=\frac{\mathrm{d}}{\mathrm{d}d}\int_{-\infty}^{\infty}\exp\left(-b^{2}\left(x-c\right)^{2}\right)\mathrm{erf}\left(a\left(x-d\right)\right)\,\mathrm{d}x\\ &= \int_{-\infty}^{\infty}\frac{\mathrm{\partial}}{\partial d}\exp\left(-b^{2}\left(x-c\right)^{2}\right)\mathrm{erf}\left(a\left(x-d\right)\right)\,\mathrm{d}x\\ &\overset{\mathtt{M}}{=} -\frac{2a}{\sqrt{\pi}}\int_{-\infty}^{\infty}\exp\left(-b^{2}\left(x-c\right)^{2}-a^{2}\left(x-d\right)^{2}\right)\,\mathrm{d}x\\ &=-\frac{2a}{\sqrt{\pi}}\int_{-\infty}^{\infty}\exp\left(-\left(a^{2}+b^{2}\right)\left(x-\frac{b^{2}c+a^{2}d}{a^{2}+b^{2}}\right)^{2}+\frac{\left(b^{2}c+a^{2}d\right)^{2}}{a^{2}+b^{2}}-\left(b^{2}c^{2}+a^{2}d^{2}\right)\right)\,\mathrm{d}x\\ & =-\frac{2a}{\sqrt{\pi}}\exp\!\left(\frac{\left(b^{2}c+a^{2}d\right)^{2}}{a^{2}+b^{2}}-\left(b^{2}c^{2}+a^{2}d^{2}\right)\right)\int_{-\infty}^{\infty}\exp\left(-\left(a^{2}+b^{2}\right)\left(x-\frac{b^{2}c+a^{2}d}{a^{2}+b^{2}}\right)^{2}\right)\,\mathrm{d}x\\ &\overset{\mathtt{*}}{=}-\frac{2a}{\sqrt{\pi}}\exp\left(-\frac{a^{2}b^{2}}{a^{2}+b^{2}}\left(c-d\right)^{2}\right)\int_{-\infty}^{\infty}\exp\left(-\left(a^{2}+b^{2}\right)y^{2}\right)\,\mathrm{d}y\\ & \overset{\mathtt{M}}{=}-\frac{2a}{\sqrt{a^{2}+b^{2}}}\exp\left(-\frac{a^{2}b^{2}\left(c-d\right)^{2}}{a^{2}+b^{2}}\right). \end{aligned} } $$ $\overset{\mathtt{*}}{=}$ substitution $y=x-\frac{b^{2}c+a^{2}d}{a^{2}+b^{2}}$

$\overset{\mathtt{M}}{=}$ calculated with Mathematica

Thus

$$ \begin{aligned} I\left(d\right)&=-\frac{2a}{\sqrt{a^{2}+b^{2}}}\int\exp\left(-\frac{a^{2}b^{2}\left(c-d\right)^{2}}{a^{2}+b^{2}}\right)\,\mathrm{d}d\\ & \overset{\mathtt{M}}{=}\frac{\sqrt{\pi}}{b}\mathrm{erf}\left(\frac{ab\left(c-d\right)}{\sqrt{a^{2}+b^{2}}}\right)+C. \end{aligned} $$

And it can be easily shown that $C=0$.

Now, I would like to evaluate a similar integral with different limits:

$$ \int_{0}^{\infty}\exp\left(-b^{2}\left(x-c\right)^{2}\right)\mathrm{erf}\left(a\left(x-d\right)\right)\,\mathrm{d}x. $$

It seems to me that the first obvious difference is doing $\int_{0}^{\infty}\exp\left(-\left(a^{2}+b^{2}\right)y^{2}\right)\,\mathrm{d}y = \frac{\sqrt\pi}{2\sqrt{a^{2}+b^{2}}}$ instead of $ \int_{-\infty}^{\infty}\exp\left(-\left(a^{2}+b^{2}\right)y^{2}\right)\,\mathrm{d}y =\frac{\sqrt\pi}{\sqrt{a^{2}+b^{2}}}$ in the line starting with $\overset{\mathtt{*}}{=}$.

Also, assuming $d\rightarrow+\infty$, $C = -\frac{\sqrt{\pi }}{2 b}\mathrm{erf}\left(bc\right)$.

In conclusion, the integral in question should evaluate to $$ \int_{0}^{\infty}\exp\left(-b^{2}\left(x-c\right)^{2}\right)\mathrm{erf}\left(a\left(x-d\right)\right)\,\mathrm{d}x = \frac{\sqrt{\pi}}{2b}\mathrm{erf}\left(\frac{ab\left(c-d\right)}{\sqrt{a^{2}+b^{2}}}\right) -\frac{\sqrt{\pi }}{2 b}\mathrm{erf}\left(bc\right) $$

but it is not correct.

So, does the differentiation under integral sign method fail for some reason in this case, or am I making some silly mistake?

Thanks.