<s>[INST] How to solve $\int_0^\pi \frac{x\sin x}{1+ \sin^2 x}dx$? I have solved
$$\int_0^\pi \frac{x\sin x}{1+ \cos^2 x}dx=\pi^2/4$$. But I cannot solve it with the same way that I used for the upper problem. Can you help me to solve this problem?  
$$\int_0^\pi \frac{x\sin x}{1+ \sin^2 x}dx$$
 [/INST] We are going to evaluate the integral
$\displaystyle \int_{0}^{\pi} \frac{x \sin x}{1+\sin ^{2} x} d x \tag*{} $
by substitution, odd and even functions.
Let  $\displaystyle y=x-\frac{\pi}{2},$ then
$\displaystyle \quad \int_{0}^{\pi} \frac{x \sin x}{1+\sin ^{2} x} d x \\$
$\displaystyle=\int_{-\frac{\pi}{2}}^{\frac{\pi}{2}} \frac{y \cos y}{1+\cos ^{2} y} d y+\frac{\pi}{2}\int_{-\frac{\pi}{2}}^{\frac{\pi}{2}} \frac{\cos y}{1+\cos ^{2} y} d y$
$\displaystyle =0+\frac{\pi}{2} \int_{-\frac{\pi}{2}}^{\frac{\pi}{2}} \frac{d(\sin y)}{2-\sin ^{2} y}$
$\displaystyle =-\pi \int_{0}^{1} \frac{d z}{z^{2}-2} \quad \text {, where } z=\sin y$
$\displaystyle =-\frac{\pi}{2\sqrt{2}} \ln \left|\frac{z-\sqrt{2}}{z+\sqrt{2}}\right|_{0}^{1}$
$\displaystyle = \frac{\pi}{\sqrt{2}} \ln (\sqrt{2}+1)$
</s>