# Integrating $xe^{a/x^2 - x^2}\text{Erfi}(x/\sqrt{2})$?

I want to solve any of the two integrals for the complex number $a$ \begin{aligned} I_1 & = \int\limits_{0}^{\infty} xe^{a/x^2 - x^2}\text{Erfi}(x/\sqrt{2}) dx\\ I_2 & = \int\limits_{0}^{\infty} \frac{1}{x}e^{a/x^2 - x^2}\text{Erfi}(x/\sqrt{2}) dx, \end{aligned} where \begin{aligned} a & \in \mathbb{C}\\ \text{Re}[a] & < 0. \end{aligned}

Solving one integral, I can get the other through the relation $$I_2 = \frac{d I_1}{da}.$$

## My approach

I can not get an answer out of Mathematica. Below are some of the approaches I tried.

a) Integration by parts
I can simplify the integrand enormously by taking the derivative of Erfi, which can be done by integration of parts. I know that the definite integral $\int_{0}^{\infty}e^{a/z^2-z^2}z^n dz$ is related to the Bessel functions, but I need the indefinite integral when doing partial integration, which I can not find.

b) Using a known integral
I know that \begin{aligned} \int\limits_{0}^{\infty}e^{1/x^2 -b^2x^2}\text{Erfc}(\frac{1}{x})dx & = \frac{1}{b\sqrt{\pi}}\left[\sin(2b\cdot\text{Ci}(2b))-\cos(2b\cdot\text{si}(2b))\right] \\ \int\limits_{0}^{\infty}e^{1/x^2 -b^2x^2}\text{Erfc}(\frac{1}{x})xdx & = \frac{\pi}{2b}\left[H_1(2b) - Y_1(2b)-\frac{1}{b}\right], \quad |\text{arg}\,b| < \frac{\pi}{4} \\ \int\limits_{0}^{\infty}e^{1/x^2 -b^2x^2}\text{Erfc}(\frac{1}{x})\frac{dx}{x} & = \frac{\pi}{2}\left[H_0(2b) - Y_0(2b)\right], \quad |\text{arg}\,b| < \frac{\pi}{4} \\ \end{aligned} where Ci and si are the Cosine and Sine integrals, and $H$ is the Struve function. What I try to do is to make the variable substitution $z\to\frac{1}{z}$, then to turn Erfi into Erf (and Erfc) with the same argument as in the above equation $z \to \frac{iz}{\sqrt{2}}$. I can not figure out the limits however when doing this last substitution.

c) Rewriting the integrand
I can rewrite the integrals as \begin{aligned} I_1 & = \int\limits_{0}^{\infty} e^{a(1/x - x)}\text{Erfi}(\sqrt{\sqrt{a}x/2}) dx\\ I_2 & = \int\limits_{0}^{\infty} \frac{1}{x}e^{a(1/x - x)}\text{Erfi}(\sqrt{\sqrt{a}x/2}) dx. \end{aligned}

Let us take $$a>0$$ and $$b>0$$ and denote : $$\begin{eqnarray} I_2(a,b)&:=&\int\limits_0^\infty \frac{1}{x} \exp( -\frac{a}{x^2}-x^2 ) erfi(b x) dx\\ I_1(a,b)&:=&\int\limits_0^\infty x \exp( -\frac{a}{x^2}-x^2 ) erfi(b x) dx \end{eqnarray}$$

Then clearly we have: $$\begin{eqnarray} \partial_b I_2(a,b) &=& \frac{2}{\sqrt{\pi}} \int\limits_0^\infty \exp( -\frac{a}{x^2}-(1-b^2)x^2 ) dx = \\ &=& \left. \frac{ \left(e^{-2 \sqrt{a} \sqrt{1-b^2}} \left(1-\text{erf}\left(\frac{\sqrt{a}}{x}-\sqrt{1-b^2} x\right)\right)+e^{2 \sqrt{a} \sqrt{1-b^2}} \left(\text{erf}\left(\frac{\sqrt{a}}{x}+\sqrt{1-b^2} x\right)-1\right)\right)}{2 \sqrt{1-b^2}} \right|_{0}^\infty=\\ &=& \frac{ e^{-2 \sqrt{a-a b^2}}}{ \sqrt{1-b^2}} \end{eqnarray}$$ Now we integrate: $$\begin{eqnarray} I_2(a,b) &=& \int\limits_0^b \frac{ e^{-2 \sqrt{a} \sqrt{1- \xi^2}}}{ \sqrt{1-\xi^2}} d\xi\\ &=& \int\limits_0^{\arcsin(b)} \exp(-2 \sqrt{a} \cos(\theta)) d\xi \\ &=& J_0(2 \imath \sqrt{a}) \arcsin(b) + 2 \sum\limits_{n=1}^M \frac{i^n}{n} J_n(2 \imath \sqrt{a}) \cdot \sin(n \arcsin(b)) \end{eqnarray}$$ where in the last line we took some integer $$M >> 1$$ and we used the generating function for Bessel functions https://en.wikipedia.org/wiki/Bessel_function . The series converge quite rapidly and taking $$M=10$$ suffices completely as the code below demonstrates:

 In[1412]:= {a, b} =
RandomReal[{0, 1}, 2, WorkingPrecision -> 50]; M = 10;
NIntegrate[1/x Exp[-a/x^2 - x^2] Erfi[b x], {x, 0, Infinity}]
NIntegrate[Exp[-2 Sqrt[a] Sqrt[1 - xi^2]]/Sqrt[1 - xi^2], {xi, 0, b}]
NIntegrate[Exp[-2 Sqrt[a] Cos[th]], {th, 0, ArcSin[b]}]
BesselJ[0, 2 I Sqrt[a]] ArcSin[b] +
2 Sum[  I^n/n BesselJ[n, 2 I Sqrt[a]] Sin[n ArcSin[b]], {n, 1, M}]

Out[1413]= 0.0832502

Out[1414]= 0.0832502

Out[1415]= 0.0832502

Out[1416]= 0.0832501731615361275633199191686069096124674656008


Now the other integral is obtained by differentiation. We have: $$\begin{eqnarray} I_1(a,b)&=&-\left.\frac{d}{d c} I_2(a \cdot c, \frac{b}{\sqrt{c}}) \right|_{c=1}\\ &=&\frac{b J_0\left(2 i \sqrt{a}\right)}{2 \sqrt{1-b^2}}+i \sqrt{a} J_1\left(2 i \sqrt{a}\right) \sin ^{-1}(b) + \\ && \sum\limits_{n=1}^M \frac{\imath^n}{n} \left( i \sqrt{a} \left(J_{n-1}\left(2 i \sqrt{a}\right)-J_{n+1}\left(2 i \sqrt{a}\right)\right) \sin \left(n \sin ^{-1}(b)\right)-\frac{b n J_n\left(2 i \sqrt{a}\right) \cos \left(n \sin ^{-1}(b)\right)}{\sqrt{1-b^2}}\right) \end{eqnarray}$$

In[1473]:= {a, b} =
RandomReal[{0, 1}, 2, WorkingPrecision -> 50]; M = 10;
NIntegrate[x Exp[-a/x^2 - x^2] Erfi[b x], {x, 0, Infinity}]
b/2 1/Sqrt[1 - b^2] -
Sum[I^n NIntegrate[BesselJ[n, 2 I Sqrt[xi]], {xi, 0, a}] If[n == 0,
ArcSin[b], (Exp[I n ArcSin[b]] - 1)/(I n)] , {n, -M, M}]
b/2 1/Sqrt[1 - b^2] -
NIntegrate[(BesselJ[0, 2 I Sqrt[xi]] ArcSin[b] +
Sum[ BesselJ[n,
2 I Sqrt[xi]] ( -((
I I^-n E^(-I n ArcSin[b]) (-1 + E^(I n ArcSin[b])) ((-1)^n +
E^(I n (\[Pi] + ArcSin[b]))))/n)), {n, 1, M}]), {xi, 0, a}]
c =.; (-D[BesselJ[0, 2 I Sqrt[a c]] ArcSin[b/Sqrt[c]], c] -
2 Sum[  I^n/n D[BesselJ[n, 2 I Sqrt[a c]] Sin[n ArcSin[b/Sqrt[c]]],
c], {n, 1, M}] /. c :> 1)
(b BesselJ[0, 2 I Sqrt[a]])/(2 Sqrt[1 - b^2]) +
I Sqrt[a] ArcSin[b] BesselJ[1, 2 I Sqrt[a]] -
Sum[  I^n/
n (-((b n BesselJ[n, 2 I Sqrt[a]] Cos[n ArcSin[b]])/ Sqrt[
1 - b^2]) +
I Sqrt[a] (BesselJ[-1 + n, 2 I Sqrt[a]] -
BesselJ[1 + n, 2 I Sqrt[a]]) Sin[n ArcSin[b]]), {n, 1, M}]

Out[1474]= 0.193704

Out[1475]= 0.193704 - 8.40823*10^-20 I

Out[1476]= 0.193704 + 0. I

Out[1477]= 0.1937040115438800579341627452243157963570649708871

Out[1478]= 0.1937040115438800579341627452243157963570649708871


Update: Finally let us consider a third integral: $$$$I_3(a,b) := \int\limits_0^\infty \exp(-\frac{a}{x^2}-x^2) erfi(b x) dx$$$$ Then by differentiating the quantity in question with respect to $$b$$ then by using Integral involving a power function and $\exp(-a/x^2-b x^2)$. and finally by integrating the result over $$b$$ we obtained the following result: $$\begin{eqnarray} I_3(a,b) = \frac{2 \sqrt{a}}{\sqrt{\pi}} \int\limits_0^{\arcsin(b)} K_1(2 \sqrt{a} \cos(\phi) ) d\phi \end{eqnarray}$$ Unfortunately I know too little about Bessel function now to be able to simplify that any further.