# How to solve this awful integral?

I have an integral for which the published solution is very simple, yet Mathematica spits out several lines of junk (much longer than the published result, with references to numerical evaluation of complex integrals).

The integral is

$$\int_{-\infty}^\infty\frac{dp}{2\pi h}\frac{e^{ip(x-x')/h}}{E-\frac{p^2}{2m} + i\epsilon}$$

for which the published result is

$$\frac{-im}{h^2k}e^{\pm ik(x-x')}$$

where the sign of the power in the exponential depends on the sign of $$(x-x')$$ (this also depends on subbing $$E=h^2k^2/2m$$, which I do below). They say they rely on "contour integration"... I'm not sure how that applies here, or if there's a simpler way

Mathematica gives the following for the $$(x-x')>0$$ case:

• Hi could you add the limits of the integration, looks like it should have some. It's probably $(-\infty,\infty)$ ? Commented Apr 1, 2020 at 15:23
• It can't be an indefinite integral because that would still depend on $p$ and your result doesn't. Presumably you want to integrate from $-\infty$ to $\infty$ (which will converge because you have decay at infinity and have moved the singularity from the denominator off the real axis with the $i\epsilon$) and for that something like residue integration is helpful. Things like residue integration can often give a result for an integral on the whole line in terms of elementary functions even when the antiderivative of the integrand is not an elementary function.
– Ian
Commented Apr 1, 2020 at 15:26
• @BenedictW.J.Irwin yes, apologies; edited Commented Apr 1, 2020 at 15:27
• So now try asking Mathematica to do the integration on the line instead of asking for the indefinite integral. Note you may need to inform it explicitly that $\epsilon$ is a positive real number.
– Ian
Commented Apr 1, 2020 at 15:28
• Indeed I find that Wolfram Alpha gives the answer in exact form at least once I freeze values of the parameters, so proper Mathematica should be able to do it with the parameters symbolic at least once suitable assumptions for them are given.
– Ian
Commented Apr 1, 2020 at 15:32

Physicist's note before we start calculations: every $$h$$ in here should really be an $$\hbar$$, but I'll stick with the OP's notation as if the physical context of this problem was unknown.
We'll begin by rewriting the integral with $$\epsilon=0$$ as $$\frac{-m}{\pi h}\int_{\Bbb R}\frac{e^{ip(x-x^\prime)/h}}{p^2-(hk)^2}$$. We can now continue by the residue theorem. If $$x-x^\prime$$ has sign $$\pm$$, the pole at $$p=\pm hk$$ contributes$$\pm 2\pi i\frac{-m}{\pi h}\lim_{p\to\pm hk}\frac{e^{ip(x-x^\prime)/h}}{p\pm hk}=\frac{-im}{h^2k}e^{\pm ik(x-x^\prime)}.$$