TITLE: The integral $\int_0^\infty \dfrac{x \sin(x)}{x^2+1} dx$
QUESTION [6 upvotes]: 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?

REPLY [2 votes]: I will share my work with you and hope that you can tell me if I understood everything well. I used two paths:
$$
\left\{ \begin{array}{ll}
          A \quad = \quad [-R,R] \ \cup \ \{Re^{i\phi} \ : \ 0 \leq \phi \leq \pi\}  \\
          B \quad = \quad[-R,R] \ \cup \ \{Re^{i\phi} \ : \ \pi \leq \phi \leq 2\pi\} \end{array} \right.
$$
I call the upper part of the circle  $U$, end the lower part of the circle $L$. Both $A$ and $B$ will be followed counter clockwiseley. 
I split up the integral as 
$$
-\frac{1}{2}i \left( 
\int_\mathbb{R} \frac{xe^{i \phi}}{x^2+1}dx 
\quad - \quad
\int_\mathbb{R} \frac{xe^{i \phi}}{x^2+1}dx
\right)
$$
Next, I took
$$
\int_A \frac{xe^{i \phi}}{x^2+1}dx  
\quad = \quad 
\int_{-R}^R \frac{xe^{i \phi}}{x^2+1}dx  
\ + \ 
\int_U \frac{xe^{i \phi}}{x^2+1}dx  
$$
On $U$, we have, for high values of $R$
$$
\pi R \cdot \left| \frac{xe^{i \phi}}{x^2+1} \right| 
\ \leq \
\frac{R}{R^2-1} \cdot  \frac{\pi R}{| e^{R \sin \phi}|} 
\ \rightarrow \ 0
$$
because $\sin \phi < 0$ on this part. It's easy to show that the integral on $L$ goes to $0$ as well, so I skip it. 
It can easily be shown that the residue in $i$ equals $\frac{1}{2e}-\frac e2$, and that 
the residue in $-i$ equals $-\frac{1}{2e}+\frac e2$. Now we find:
$$
\int_\mathbb{R}\frac{x \sin x}{x^2+1}dx
\quad = \quad 
2 \int_{\mathbb{R}^+}\frac{x \sin x}{x^2+1}dx
\quad = \quad
2(\frac{1}{2e}-\frac e2)
\quad = \quad 
\frac{1}{e}- e
$$
I hope that someone could check this.