Compute the definite integral Find 
$$\int_0^{\pi}\frac{x}{1+\cos^2(x)}dx$$
I tried letting $u=\tan(\frac{x}{2})$ but could not make it work. A few other trig substitutions failed as well. I noticed the integrand is odd but could not make use of that fact. Any ideas?
 A: Note that the denominator is symmetric with respect to $\frac{\pi}{2}$. So we have
$$\int_0^\pi \frac{x}{1+\cos^2 x}\,dx = \frac{\pi}{2}\int_0^\pi \frac{1}{1+\cos^2 x}\,dx + \int_0^\pi \frac{x-\frac{\pi}{2}}{1+\cos^2 x}\,dx,$$
and the integrand of the second integral is "odd with respect to $\frac{\pi}{2}$", so
$$\int_0^\pi \frac{x}{1+\cos^2 x}\,dx = \frac{\pi}{2}\int_0^\pi \frac{1}{1+\cos^2 x}\,dx.$$
We can evaluate that integral using the residue theorem similar to this, and obtain
$$\int_0^\pi \frac{x}{1+\cos^2 x}\,dx = \frac{\pi^2}{2\sqrt{2}}.$$
A: Break up into $A$, the integral from $0$ to $\pi/2$, plus $B$, the integral from $\pi/2$ to $\pi$,  For the second integral, make the change of variable $x=\pi -u$.
We get
$$B=\int_{x=\pi/2}^{\pi} \frac{x}{1+\cos^2 x}\,dx=\int_{\pi/2}^{0} -\frac{\pi-u}{1+\cos^2 u}\,du.$$
With sign changes, and replacement of the letter $u$ by the letter $x$, we get that
$$B=\int_{0}^{\pi/2} \frac{\pi-x}{1+\cos^2 x}\,dx.$$
Add $A$. We get that 
$$A+B=\int_0^{\pi/2}\frac{\pi}{1+\cos^2 x}\,dx.$$
Now we are at a moderately standard integral.
A: use  this trigonometry identity   
$\cos^2(x) = \frac{1}{2}+\frac{1}{2}\cos(2x)$
you will get
$\dfrac{x}{3/2+cos(2x)/2}$
now
this is same as
$\dfrac{2x}{3+\cos(2x)}$
please now substitute $y=2x$
A: As $\displaystyle\int_a^bf(x)dx=\int_a^bf(a+b-x)dx,$
$I=\displaystyle\int_0^\pi\frac x{1+\cos^2x}dx=\int_0^\pi\frac{\pi-x}{1+\cos^2x}dx$ as $\cos(\pi-x)=-\cos x$
$\displaystyle\implies I+I=\pi\int_0^\pi\frac1{1+\cos^2x}dx$
Now  $\displaystyle \int_0^{2a}f(x)dx=
\begin{cases} 2\int_0^af(x)dx &\mbox{if } f(2a-x)=f(x) \\ 
0 & \mbox{if } f(2a-x)=-f(x) \end{cases} $
Here $\displaystyle a=\frac\pi2\implies \int_0^\pi\frac1{1+\cos^2x}dx=2\int_0^{\frac\pi2}\frac1{1+\cos^2x}dx $
Now $\displaystyle\int\frac1{1+\cos^2x}dx=\int\frac{\sec^2x}{2+\tan^2x}dx $
Set $\tan x=u$
