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.    
 A: 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}.$$
A: 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.
