# Mathematica returns incorrect evaluation of integral

Consider the integral $$\begin{equation} u(x):= \lim_{\eta \to 0^+}\int_{-\infty}^\infty \frac{d s}{s^2 + 1} \left( \frac{1}{x - i \eta - \sqrt{s^2 + 1}} - \frac{1}{x - i \eta + \sqrt{s^2 + 1}} \right) . \end{equation}$$ for $$x \in \mathbb{R}$$.

Mathematica will evaluate this integral without complaint

In[] : = Assuming[x \[Element] Reals && \[Eta] > 0, Limit[Integrate[1/(s^2 + 1) (1/(x - I \[Eta] - Sqrt[s^2 + 1]) - 1/(x - I \[Eta] + Sqrt[s^2 + 1])), {s, -\[Infinity], \[Infinity]}], \[Eta] -> 0, Direction -> "FromAbove"]]


and returns $$u_\mathrm{MMA}(x) = -\frac{4 \arccos\left(\sqrt{1-x^2}\right)}{\left| x\right| \sqrt{1-x^2} }$$ However this answer cannot be correct, it is an even function ($$u(-x) = u(x)$$), whereas the definition manifestly has the propery $$u(-x) = u(x)^*$$ (this can be confirmed using NIntegrate for small finite values of $$\eta$$). I.e. both the real and imaginary parts of $$u_\mathrm{MMA}(x)$$ are even, when the imaginary part should be odd.

Is there a way of getting Mathematica to return the correct answer for these types of integral?

• In 12.2 on Windows 10 Pro I obtain$$\fbox{-\frac{4 \cos ^{-1}\left(\sqrt{1-x^2}\right)}{\sqrt{x^2-x^4}}\text{ if }-1<x<1}$$ May 18, 2021 at 13:47
• @user64494 That's interesting. I am running version 12.0.0 on Mac OS X x86 (64bit). May 18, 2021 at 13:49
• And $$\frac{4 \cos ^{-1}\left(\sqrt{1-(x-i \eta )^2}\right)}{\sqrt{(x-i \eta )^2-(x-i \eta )^4}}$$ for the integral under consideration. May 18, 2021 at 13:50
• @user64494 nonetheless your result is still even in $x$? And therefore still incorrect? May 18, 2021 at 13:50
• Note that the 12.2 answer, given the assumption that $|x| < 1$, is real; and therefore $u(-x) = u^*(x) \Leftrightarrow u(-x) = u(x)$ under these assumptions. May 18, 2021 at 14:02

The issue appears to be that Mathematica is handling the assumptions concerning x incorrectly. If you explicitly tell it that $$x < -1$$, $$|x| \leq 1$$, or $$x > 1$$, it produces three slightly different functional forms:

ulow[x_] = Assuming[x < -1 && \[Eta] > 0, ... ]
umid[x_] = Assuming[1 > x > -1 && \[Eta] > 0, ... ]
uhigh[x_] = Assuming[1 < x && \[Eta] > 0, ... ]

(* (4 I (\[Pi] + ArcSin[x]))/(x Sqrt[-1 + x^2]) *)
(* -((4 ArcCos[Sqrt[1 - x^2]])/Sqrt[x^2 - x^4]) *)
(* (4 I ArcSin[x])/(x Sqrt[-1 + x^2]) *)


So if desired, we can assemble these into a Piecewise function that works for all x:

u[x_] := Piecewise[{{ulow[x], x< -1}, {umid[x], -1 <= x <= 1}, {uhigh[x], x > 1}}]
Plot[Evaluate[ReIm[u[x]]], {x, -Pi, Pi}] This does appear to have the property that $$\Re(u(x))$$ is even in $$x$$ and $$\Im(u(x))$$ is odd in $$x$$.

• Great, thank you. This is a useful workaround. It is a shame that it requires identifying the discontinuities by hand. May 18, 2021 at 14:17