TITLE: Evaluate $\int _0 ^ \pi \frac{x}{1+\sin^2(x)} dx $
QUESTION [8 upvotes]: Find the value of
  $$\int _0 ^ \pi \dfrac{x}{1+\sin^2(x)} dx $$

I have tried using $\int_a ^bf(x) dx=\int_a^b f(a+b-x)dx$
$\displaystyle \int _0 ^ \pi \dfrac{x}{1+\sin^2(x)} dx=\int _0 ^ \pi \dfrac{\pi-x}{1+\sin^2(x)} dx=I$
I couldn't go any further with that!

REPLY [8 votes]: Now add the two integrals to get
$$2I=\pi\int_0^{\pi}\frac{dx}{1+\sin^2x}=\pi\int_{0}^{2\pi}\frac{dy}{3-\cos y},\tag{1}$$
where we used $\cos2x=1-2\sin^2x$ and the change of variables $y=2x$ to get the second equality.
The last integral in (1) can be easily calculated by residues (in fact the integrals of this type are the most standard and straightforward application of the residue theorem) so that finally
$$I=\frac{\pi^2}{2\sqrt{2}}.$$

Added: (the computation of (1) without residues) The change of variables $t=\tan x$ allows to write
$$\sin^2x=\frac{t^2}{1+t^2},\qquad dx=\frac{dt}{1+t^2},$$
so that 
\begin{align}
\int_0^{\pi}\frac{dx}{1+\sin^2x}=2\int_0^{\pi/2}\frac{dx}{1+\sin^2x}=2
\int_0^{\infty}\frac{dt}{1+2t^2}=\sqrt{2}\Bigl[\arctan(t\sqrt{2})\Bigr]_{0}^{\infty}
=\frac{\pi}{\sqrt{2}}.
\end{align}

REPLY [2 votes]: $I$ =$\int _0 ^ \pi \dfrac{x}{1+\sin^2(x)} dx$
also $\int _0 ^ \pi \dfrac{\pi-x}{1+\sin^2(x)} dx=I$
add both to get,
$2I$ =  $\int _0 ^ \pi \dfrac{\pi}{1+\sin^2(x)} dx$
AND FURTHER SOLVE IT.