Why Wolfram gives inconsistent result for: $\int_0^\infty \frac{e^{x-x^2}-e^{-x-x^2}}{x}~dx$

212 Views Asked by At

Why Wolfram gives inconsistent result for :

$$I=\int_0^\infty \frac{e^{x-x^2}-e^{-x-x^2}}{x}~dx$$

As shown in the picture below, the analytical integration gives $-i\pi$, but numerical integration gives $1.93193$. The result must be a real number, but why Wolfram gives a complex result for the analytical integration?

What I suspect is Wolfram might treat this integral as Frullani integral, where $f(x)=e^{x-x^2}$, and $f(-x)=e^{-x-x^2}$. We get

$$\int_0^\infty \frac{e^{x-x^2}-e^{-x-x^2}}{x}~dx=\int_0^\infty \frac{f(x)-f(-x)}{x}~dx=(f(\infty)-f(0))\ln\left(\frac1{-1}\right)=-i\pi$$ But this is WRONG!

enter image description here

2

There are 2 best solutions below

3
On

Just a few elements (using Mathematica 13.1.0.0)

  • First case

$$I_1=\int_0^\infty \frac{e^{a x-x^2}-e^{-a x-x^2}}{x}\,dx=\log (a)-\log (-a)=-i\,\pi$$

  • Second case

$$I_2=\int_0^\infty \frac{e^{a x-b x^2}-e^{-a x-c x^2}}{x}\,dx=$$ $$\frac{1}{4} a^2 \left(\frac{\, _2F_2\left(1,1;\frac{3}{2},2;\frac{a^2}{4 b}\right)}{b}-\frac{\, _2F_2\left(1,1;\frac{3}{2},2;\frac{a^2}{4 c}\right)}{c}\right)+$$ $$\frac{1}{2} \left(\pi \left(\text{erfi}\left(\frac{a}{2 \sqrt{b}}\right)+\text{erfi}\left(\frac{a}{2 \sqrt{c}}\right)\right)-\log (b)+\log (c)\right)$$ If $c=b$, this reduces to $$I_2=\pi \, \text{erfi}\left(\frac{a}{2 \sqrt{b}}\right)$$

  • Third case $$I_3=\int_0^\infty \frac{e^{a x-b x^2}-e^{-a x-b x^2}}{x}\,dx=\int_0^\infty\frac{2 \sinh (a x)}{x} e^{-b x^2}\,dx$$ $$I_3=\pi \, \text{erfi}\left(\frac{a}{2 \sqrt{b}}\right)$$
0
On

Feynman’s trick

Consider the parametrised integral by $a$, $$ I(a)=\int_0^{\infty} \frac{e^{a x-x^2}-e^{-a x-x^2}}{x} d x $$ where $I(0)=0.$ $$ \begin{aligned} I’(a)=&\int_0^{\infty} e^{-\left(x-\frac{a}{2}\right)^2+\frac{a^2}{4}} d x-\int_0^{\infty} e^{-\left(x+\frac{a}{2}\right)^2+\frac{a^2}{4}} d x \\ = & e^{\frac{a^2}{a}}\left[\int_0^{\infty} e^{-\left(x-\frac{a}{2}\right)^2} d x-\int_0^{\infty} e^{-\left(x+\frac{a}{2}\right)^2} d x\right] \\ = & \frac{e^{\frac{a^2}{4}}}{2} \sqrt{\pi}\left[\operatorname{erf}\left(\frac{a}{2}\right)+1+\operatorname{erfc}\left(\frac{a}{2}\right)\right] \\ = & \sqrt{\pi} e^{\frac{a^2}{4}} \end{aligned} $$ Integrating from $a=0$ to $1$ yields $$ I(1)=\sqrt{\pi} \int_0^1 e^{\frac{a^2}{4}} d a $$ Hence we can conclude that $$ \boxed{\int_0^{\infty} \frac{e^{x-x^2}-e^{-x-x^2}}{x} d x=\sqrt{\pi}\left[\sqrt{\pi} \operatorname{erfi}\left(\frac{1}{2}\right)\right]=\pi\operatorname{erfi}\left( \frac{1}{2}\right)\approx {1.93193}\;} $$ which doesn’t agree with WA.