Evaluate $\int_{0}^{\infty} \frac{\sin x-x\cos x}{x^2+\sin^2x } dx$

$$ I=\int_{0}^{\infty} \frac{\sin x-x \cos x}{x^2+\sin^2 x} dx= - \int_{0}^{\infty}\frac{\frac {x\cos x -\sin x}{x^2}}{1+(\frac{\sin x}{x})^2}dx= -\int_{1}^{0} \frac{dt}{1+t^2}=\frac{\pi}{4}.$$


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} $$