Evaluate $\int_{0}^{\infty} \frac{\sin x-x\cos x}{x^2+\sin^2x } dx$ The integral  $$\int_{0}^{\infty} \frac{\sin x-x\cos x}{x^2+\sin^2x } dx$$ admits
a nice closed form. The question is: How to evaluate it by hand.

Note that
$$
\begin{align}
\frac{\mathrm{d}}{\mathrm{d}x}\log(x-i\sin(x))
&=\frac{1-i\cos(x)}{x-i\sin(x)}\\
&=\frac{x+\sin(x)\cos(x)}{x^2+\sin^2(x)}+i\frac{\sin(x)-x\cos(x)}{x^2+\sin^2(x)}
\end{align}
$$
Taking the imaginary part of both sides
$$
\begin{align}
\frac{\mathrm{d}}{\mathrm{d}x}\frac1{2i}\log\left(\frac{x-i\sin(x)}{x+i\sin(x)}\right)
&=\frac{\sin(x)-x\cos(x)}{x^2+\sin^2(x)}
\end{align}
$$
Thus,
$$
\int\frac{\sin(x)-x\cos(x)}{x^2+\sin^2(x)}\,\mathrm{d}x
=\frac1{2i}\log\left(\frac{x-i\sin(x)}{x+i\sin(x)}\right)+C
$$
and
$$
\begin{align}
\int_0^\infty\frac{\sin(x)-x\cos(x)}{x^2+\sin^2(x)}\,\mathrm{d}x
&=-\frac1{2i}\log\left(\frac{1-i}{1+i}\right)\\
&=\frac\pi4
\end{align}
$$
