How to calculate: $$\int_0^\infty \frac{x \sin(x)}{x^2+1} dx$$ I thought I should find the integral on the path $[-R,R] \cup \{Re^{i \phi} : 0 \leq \phi \leq \pi\}$.
I can easily take the residue in $i$ $$ Res_{z=i} \frac{x \sin(x)}{x^2+1} \quad = \quad \frac{i (e^{ii}-e^{-ii})}{2i} \quad = \quad \frac{i(\frac1e-e)}{2i} \quad = \quad \frac1{2e}-\frac e2 $$ I know that the integral on $[-R,R]$ will get nearby the real value of $ \frac12\int_0^\infty \frac{x \sin(x)}{x^2+1} dx$. That means that I'm done if I show that the integral on the other part of the path will be small, here is an attempt to do so:
$$ \left|\frac{x \sin(x)}{x^2+1} \right| \quad \leq \quad R \cdot \frac{|\sin x|}{R^2-1} $$ I could rewrite $\sin x$ but it becomes nasty. Can you help me with this?
Remember that $\sin x=(\exp(ix)-\exp(-ix))/2i$, and $\exp(-ix)$ grows large in the upper half plane. You have to integrate the $\exp(ix)$ part in the upper half plane, and the $\exp(-ix)$ in the lower half plane.
Also, the upper half-plane is $0<\phi<\pi$, not $2\pi$.
The trick of completing the loop does two things.
Firstly, the integral around a loop equals the sum of the residues, which are easy to calculate.
Secondly, the extra semicircle involves large values of $x$, so the function is very small along the semicircle, and the contribution along the semicircle is negligible. So, put together, the integral you want - along the diameter - plus the negligible amount along the semicircle, equals the sum of the residues.
So we make some effort to ensure the integral along the semicircle is negligible. $\exp(iz)=\exp(ix-y)$, so its absolute value is $e^{-y}$. The upper half plane is fine to integrate $\exp(iz)z/(1+z^2)$.
But $\exp(-iz)$ has absolute value $e^y$, so contributions will be large in the upper half plane. We integrate $\exp(-iz)z/(1+z^2)$ in the lower half plane instead. The integral along the diameter is the same it always was, but the residue is now anticlockwise around $-i$.