I am trying to evaluate this integral using integration by parts.
$$I=\int_{0}^{\infty}f(x)g'(x)dx,$$ where $f(x)=\sin x$ and $g'(x)=\dfrac{x}{1+x^2}$. So: $f'(x)=\cos x$ and $g(x)=\dfrac{1}{2}\log(1+x^2)$.
Therefore: $$\begin{equation}\begin{split}I=\int_{0}^{\infty}f(x)g'(x)dx&=\left[f(x)g(x)\right]_{0}^{\infty}-\int_{0}^{\infty}f'(x)g(x)dx,\\&=\left[\dfrac{1}{2}\log (1+x^2)\sin x\right]_{0}^{\infty}-\underbrace{\int_{0}^{\infty}\dfrac{1}{2}\log(1+x^2)\cos x\,dx}_{\text{another integration by parts}},\\&=\left[\dfrac{1}{2}\log (1+x^2)\sin x\right]_{0}^{\infty}-\dfrac{1}{2}\left(\left[-\log (1+x^2)\sin x\right]_{0}^{\infty}+\\2\underbrace{\int_{0}^{\infty}\sin x\dfrac{x}{1+x^2}dx}_{I}\right)\\&=\left[\log (1+x^2)\sin x\right]_{0}^{\infty}-I.\end{split}\end{equation}$$
Thus, $$I=\left[\dfrac{1}{2}\log (1+x^2)\sin x\right]_{0}^{\infty}=\lim_{x\to\infty}\dfrac{1}{2}\log (1+x^2)\sin x.$$
My question is: Whatever I did a mistake or not (of course I would like to know also), I would like to know what are the conditions to use integration by parts. Is it always allowed?