Calculus – Integral of Product of Exponential Function and Two Complementary Error Functions

calculusdefinite integralserror functionintegrationspecial functions

I found the following integral evaluation very interesting to me:

Integral of product of two error functions (erf)

and I hoped that I could use that result to evaluate the following integral:
$$
\int_{-\infty}^{\infty}\exp\left(-t^{2}\right)\,\mathrm{erfc}\left(t-c\right)\,\mathrm{erfc}\left(d-t\right)\,\mathrm{d}t=\frac{4}{\pi}\int_{-\infty}^{\infty}\exp\left(-t^{2}\right)\int_{t-c}^{\infty}\int_{d-t}^{\infty}\exp\left(-u^{2}-v^{2}\right)\,\mathrm{d}u\,\mathrm{d}v\,\mathrm{d}t
$$

So I note that $u\geq t-c$, $v\geq d-t$,
thus $t\leq u+c$ and $t\geq d-v$,
thus $d-v\leq t\leq u+c$ and $u+v\geq d-c$.

Hence
$$
\frac{4}{\pi}\int_{-\infty}^{\infty}\exp\left(-t^{2}\right)\int_{d-t}^{\infty}\int_{t-c}^{\infty}\exp\left(-u^{2}-v^{2}\right)\,\mathrm{d}u\,\mathrm{d}v\,\mathrm{d}t=
$$
$$
\qquad\qquad =\frac{4}{\pi}\int\!\int_{u+v>d-c}\exp\left(-u^{2}-v^{2}\right)\,\int_{d-v}^{u+c}\exp\left(-t^{2}\right)\,\mathrm{d}t\,\mathrm{d}u\,\mathrm{d}v
$$

I know that
$$
\int_{d-v}^{u+c}\exp\left(-t^{2}\right)\,\mathrm{d}t=\frac{1}{2}\sqrt{\pi}\left(\mathrm{erf}\left(u+c\right)-\mathrm{erf}\left(d-v\right)\right)
$$

but I don't quite understand how I should deal with
$$\frac{4}{\pi}\int\!\int_{u+v>d-c}\exp\left(-u^{2}-v^{2}\right)\mathrm{d}u\,\mathrm{d}v\,.
$$
What limits of integration I should use there?
Thanks for any suggestions.

Best Answer

Let $c \in {\mathbb R}$ and $d \in {\mathbb R}$. Without loss of generality we can consider a slightly different function: \begin{equation} f(c,d):= \int\limits_{-\infty}^\infty \exp(-t^2) \mbox{erfc}(t-c) \mbox{erfc}(t-d) dt \end{equation} Now we differentiate with respect to $c$. We have: \begin{eqnarray} \partial_c f(c,d) &=& \lim\limits_{\epsilon \rightarrow 0} \frac{\sqrt{2}}{\sqrt{\pi}} \exp(-\frac{c^2}{2}) \left( \sqrt{\pi} + 2 \sqrt{\pi} T(\epsilon,\frac{1}{\sqrt{2}},\frac{2d-c}{\sqrt{2}}) - 2 \sqrt{\pi} T(\epsilon,\frac{1}{\sqrt{2}},\frac{-2d+c}{\sqrt{2}})\right)\\ &=&\sqrt{2} \exp(-\frac{c^2}{2}) \left( 1-erf(\frac{c-2 d}{\sqrt{6}})\right) \end{eqnarray} where $T(h,a,b)$ is the generalized Owen's T function Generalized Owen's T function .

Now, all we need to do is to integrate. Since $f(-\infty,d)=0$ we integrate over $c$ from minus infinity to $c$. We have: \begin{eqnarray} f(c,d) &=& \sqrt{2} \left( \sqrt{\frac{\pi}{2}}(1+erf(\frac{c}{\sqrt{2}}) + 2erf(\frac{d}{\sqrt{2}})) + \sqrt{2 \pi} 2 T(c,\frac{1}{\sqrt{3}},-\frac{2 d}{\sqrt{3}})\right) \\ &=& \frac{1}{3 \sqrt{\pi}} \left( 12 \pi T\left(c,\frac{c-2 d}{\sqrt{3} c}\right)+12 \pi T\left(d,\frac{d-2 c}{\sqrt{3} d}\right)-6 \arctan\left(\frac{c-2 d}{\sqrt{3} c}\right)-6 \arctan\left(\frac{d-2 c}{\sqrt{3} d}\right)+3 \pi \text{erf}\left(\frac{c}{\sqrt{2}}\right)+3 \pi \text{erf}\left(\frac{d}{\sqrt{2}}\right)+4 \pi\right) \end{eqnarray} where $T(h,a)$ is Owen's T function https://en.wikipedia.org/wiki/Owen%27s_T_function .

In[1060]:= {c, d} = RandomReal[{-2, 2}, 2, WorkingPrecision -> 50];
NIntegrate[Exp[-t^2] Erfc[t - c] Erfc[t - d], {t, -Infinity, Infinity}]
(4 \[Pi] - 6 ArcTan[(c - 2 d)/(Sqrt[3] c)] - 
 6 ArcTan[(-2 c + d)/(Sqrt[3] d)] + 3 \[Pi] Erf[c/Sqrt[2]] + 
 3 \[Pi] Erf[d/Sqrt[2]] + 12 \[Pi] OwenT[c, (c - 2 d)/(Sqrt[3] c)] + 
 12 \[Pi] OwenT[d, (-2 c + d)/(Sqrt[3] d)])/(3 Sqrt[\[Pi]])

Out[1061]= 0.483318

Out[1062]= 0.48331807775609703646923225386370751256977344715

Update: Now let us take four real numbers $a_1 \in {\mathbb R}$, $a_2 \in {\mathbb R}$, $c\in {\mathbb R}$ and $d \in {\mathbb R}$ and consider a more general integral: \begin{equation} f^{(a_1,a_2)}(c,d):= \int\limits_{-\infty}^\infty \exp(-t^2) \mbox{erfc}(a_1 t-c) \mbox{erfc}(a_2 t-d) dt \end{equation} Then by doing the same calculations as above we easily arrive at the following formula: \begin{eqnarray} &&f^{(a_1,a_2)}(c,d)= \frac{1}{\sqrt{\pi}} \left(\right.\\ && 4 \pi T\left(\frac{\sqrt{2} c}{\sqrt{a_1^2+1}},\frac{a_1 a_2 c-\left(a_1^2+1\right) d}{c \sqrt{a_1^2+a_2^2+1}}\right)+4 \pi T\left(\frac{\sqrt{2} \sqrt{a_1^2+1} d}{\sqrt{a_1^2 a_2^2+a_1^2+a_2^2+1}},\frac{a_1 a_2 d-\left(a_2^2+1\right) c}{d \sqrt{a_1^2+a_2^2+1}}\right) +\\ &&-2 \arctan\left(\frac{a_1 a_2 c-\left(a_1^2+1\right) d}{c \sqrt{a_1^2+a_2^2+1}}\right)-2 \arctan\left(\frac{a_1 a_2 d-\left(a_2^2+1\right) c}{d \sqrt{a_1^2+a_2^2+1}}\right)+\\ &&\pi \text{erf}\left(\frac{\sqrt{a_1^2+1} d}{\sqrt{a_1^2 a_2^2+a_1^2+a_2^2+1}}\right)+\pi \text{erf}\left(\frac{c}{\sqrt{a_1^2+1}}\right)+\\ &&\pi +2 \arctan\left(\frac{a_1 a_2}{\sqrt{a_1^2+a_2^2+1}}\right)\\ &&\left.\right) \end{eqnarray}

For[count = 1, count <= 200, count++,
  {a1, a2, c, d} = RandomReal[{-5, 5}, 4, WorkingPrecision -> 50];
  I1 = NIntegrate[
    Exp[-t^2] Erfc[a1 t - c] Erfc[a2 t - d], {t, -Infinity, Infinity}];
  I2 = 1/Sqrt[\[Pi]] (\[Pi] + 
      2 ArcTan[(a1  a2)/Sqrt[(1 + a1^2 + a2^2)]] - 
      2 ArcTan[ (a1 a2 c - (1 + a1^2) d)/(
        Sqrt[(1 + a1^2 + a2^2)] c)] - 
      2 ArcTan[ (a1 a2 d - (1 + a2^2) c)/(
        Sqrt[(1 + a1^2 + a2^2)] d)] + \[Pi] Erf[c/Sqrt[
        1 + a1^2]] + \[Pi] Erf[(Sqrt[(1 + a1^2)] d)/ Sqrt[
        1 + a1^2 + a2^2 + a1^2 a2^2]] + 
      4 \[Pi] OwenT[(Sqrt[2] c)/Sqrt[
        1 + a1^2],  (a1 a2 c - (1 + a1^2) d)/(
        Sqrt[(1 + a1^2 + a2^2)] c)] + 
      4 \[Pi] OwenT[(Sqrt[2] Sqrt[(1 + a1^2)] d)/ Sqrt[
        1 + a1^2 + a2^2 + a1^2 a2^2],  (a1 a2 d - (1 + a2^2) c)/(
        Sqrt[(1 + a1^2 + a2^2)] d)]);
  If[Abs[I2/I1 - 1] > 10^(-3), 
   Print["results do not match", {a1, a2, c, d, {I1, I2}}]; Break[]];
  If[Mod[count, 10] == 0, PrintTemporary[count]];
  ];
Related Question