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

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.

• $$I=\frac{\pi}{2e}+\frac{i}2(e^{-1}\operatorname{Ei}(1)-e\operatorname{Ei}(-1))$$ – Kemono Chen Oct 30 '18 at 12:00
• @KemonoChen Thank you. But yes, I am aware of the answer. I am just trying to find a complex analysis approach. The answer can also be written as $I=\text{Ci}(i)\sin(i)+\left(\frac{\pi}{2}-\text{Si}(i)\right)\cos(i)$. – user610230 Oct 30 '18 at 12:13
• I'm afraid it can not be done by residue theorem since $\frac{e^{iz}\ln(-z)}{z^2+1}$ doesn't vanish when $z\to\infty$. – Kemono Chen Oct 30 '18 at 12:16
• As a general rule: if you try to do a definite integral by contour methods, it will fail unless the two endpoints of the definite integral are "special" points of the integrand, such as poles or branch points. So in your case perhaps you may try to find two similar integrals from $-infty$ to $+\infty$ that can combine to yield your integral. – GEdgar Oct 30 '18 at 12:52

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}.$$
• Not really, a contour integral is just an integral along a path. The path doesn't have to be closed. Implicitly we do use a closed contour, namely $[0, R] \cup C_R \cup [i R, i (1 + \epsilon)] \cup C_\epsilon \cup [i (1 - \epsilon), 0]$, where $C_R$ is the quarter-circle from $R$ to $i R$. The integral over this contour is zero, while the integral over $C_R$ tends to zero for large $R$. Which is why we can deform the contour $[0, \infty)$ in the described way. – Maxim Nov 1 '18 at 13:23
Did you tried an sector in the upper half plane? Something like $$\{z=re^{i\theta}: 0<\theta\leq 3 \pi/4 \}$$? I think that's a good way, then you can use Cauchy's Theorem.