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!
Update: I use Mathematica 10.0 and Wolfram Alpha online, and both of them give the complex result.
"13.3.0 for Mac OS X ARM (64-bit) (June 3, 2023)"
Mathematica returns\[Pi] Erfi[1/2]
, i.e.,1.93193
Please edit your question to indicate version/OS that you are using. $\endgroup$Integrate[Exp[ -x^2] /x 2 Sinh[x], {x, 0, Infinity} ]
to get the right solution ` ([Pi] Erfi[1/2])` $\endgroup$