Finding a contour for $\int_{0}^{\infty}\frac{e^{ix}}{x^2+1}\text{d}x$

calculuscomplex-analysiscontour-integrationintegration

Using complex analysis, how does one solve: $$I=\int_{0}^{\infty}\frac{e^{ix}}{x^2+1}\text{d}x$$
I have been able to do this by introducing a variable and performing integration under the integral sign.

However, I would like to to achieve this via complex analysis.

Were the interval $(-\infty,\infty)$, I could think of a contour that works; just a semicircle in the upper half of the complex plane.

The problem is the interval $[0,\infty)$. I cannot think of a contour that would work for this type of integral.

Hopefully, one can help me in finding an appropriate contour.

Best Answer

Obtaining the answer is much easier when the answer is already known. Deform the contour to $[0, i (1 - \epsilon)] \cup C_\epsilon \cup [i (1 + \epsilon), i \infty)$, where $C_\epsilon$ is the half-circle of radius $\epsilon$ in the right half-plane around $i$, and let $x = i t$. Then $$\int_0^\infty \frac {e^{i x}} {x^2 + 1} dx = \\ \lim_{\epsilon \to 0^+} i \left( \int_0^{1 - \epsilon} + \int_{1 + \epsilon}^\infty \right) \left( \frac {e^{-t}} {2 (t + 1)} - \frac {e^{-t}} {2 (t - 1)} \right) dt + \lim_{\epsilon \to 0^+} \int_{C_\epsilon} \frac {e^{i x}} {x^2 + 1} dx = \\ \frac i 2 \left( \int_1^\infty \frac {e^{-t + 1}} t dt - \operatorname{v.\!p.} \int_{-1}^\infty \frac {e^{-t - 1}} t dt \right) + \pi i \operatorname*{Res}_{x = i} \frac {e^{i x}} {x^2 + 1} = \\ \frac {i (e^{-1} \operatorname{Ei}(1) - e \operatorname{Ei}(-1))} 2 + \frac \pi {2 e}.$$