Need help proving this integration If $a>b>0$, prove that :

$$\int_0^{2\pi} \frac{\sin^2\theta}{a+b\cos\theta}\ d\theta = \frac{2\pi}{b^2} \left(a-\sqrt{a^2-b^2} \right) $$


You can solve it with direct integration some subsitutions gives you  the antiderivative: 
$$\frac{-2 \sqrt{b^2-a^2} \tanh ^{-1}\left(\frac{(a-b) \tan \left(\frac{\theta }{2}\right)}{\sqrt{b^2-a^2}}\right)+a \theta -b \sin (\theta )}{b^2}$$
use a substituion like 
$t=\tan(\theta)$. (and a lot of the trigonometric identies.)
We use the identies 
\begin{align*}
\cos(\arctan(t))&=\frac{1}{\sqrt{1+t^2}}\\
\sin(\arctan(t))&=\frac{t}{\sqrt{1+t^2}}
\end{align*}
So we have 
$$\int \frac{\sin^2(\theta)}{a+b\cos(\theta)}\, \mathrm{d}\theta= \int 
\frac{t^2}{a + b \frac{1}{\sqrt{1+t^2}}} \, \mathrm{d} t$$
With residue theorem it should work like this :
$$\int_0^{2\pi} \frac{\sin^2(\theta)}{a+ b \cos(\theta)}\, \mathrm{d}\theta=
-\int_0^{2\pi} \frac{1}{4}\cdot \frac{(\exp(i \theta)- \exp(-i \theta))^2}{a+\frac{b}{2} (\exp(i\theta) +\exp(-i\theta)} \, \mathrm{d}\theta$$
Chosing the way $\gamma(\theta) = e^{i\theta}$we see that it equal
$$-\frac{1}{4i} \int_\gamma \frac{(z-z^{-1})^2}{a+ \frac{b}{2} (z+z^{-1})} \cdot \frac{1}{z} \, \mathrm{d} z$$
Expanding gives us 
$$-\frac{1}{4i} \int_\gamma \frac{z^2 -2 + \frac{1}{z^2}}{a+ \frac{b}{2} (z+\frac{1}{z})} \cdot \frac{1}{z} \, \mathrm{d}z=-\frac{1}{4i} \int_\gamma \frac{z^2 -2 + \frac{1}{z^2}}{za+ \frac{b}{2} (z^2+1)}  \, \mathrm{d}z$$
