To evaluate $\int_{0}^\pi \frac {\sin^2 x}{a^2-2ab \cos x + b^2}\mathrm dx$? How do we evaluate $\displaystyle\int_{0}^\pi \dfrac {\sin^2 x}{a^2-2ab \cos x + b^2}\mathrm dx$ ? I tried substitution and some other methods , but its not working ; please help . 
 A: Let $I$ be the integral given by 
$$I=\int_0^\pi \frac{\sin^2x}{a^2+b^2-2ab\cos x}\,dx$$
Exploiting the even symmetry of the integrand, we have
$$I=\frac12\int_{-\pi}^\pi \frac{\sin^2x}{a^2+b^2-2ab\cos x}\,dx$$
Next, using $\sin^2x=\frac12(1-\cos 2x)$ we obtain
$$\begin{align}
I&=\frac14\int_{-\pi}^\pi \frac{1-\cos 2x}{a^2+b^2-2ab\cos x}\,dx\\\\
&=\frac14\text{Re}\left(\int_{-\pi}^\pi \frac{1-e^{i2x}}{a^2+b^2-2ab\cos x}\,dx\right)
\end{align}$$
Now, we move to the complex plane. To that end, we let $z=e^{ix}$ so that $dx=\frac{1}{iz}dz$.  Then, 
$$I=\frac{1}{4ab}\text{Re}\left(i\oint_{|z|=1} \frac{1-z^2}{z^2-\frac{a^2+b^2}{ab}z+1}\,dz\right)$$
The singularities of the integrand are at $z=\frac{a^2+b^2}{2ab}\pm\frac{|a^2-b^2|}{2|ab|}$.  We will analyze the case for which $0<b<a$ with the results from other cases following from symmetry arguments.  We note that if $ab>0$, then $$\frac{a^2+b^2}{2ab}>1$$ and the only enclosed pole is at $z=\frac{a^2+b^2}{2ab}-\frac{|a^2-b^2|}{2|ab|}=b/a$ for $0<b<a$.  Therefore, the residue is given by
$$\text{Res}\left(\frac{1-z^2}{z^2-\frac{a^2+b^2}{ab}z+1},z=b/a\right)=\frac{1-(b/a)^2}{-(a^2-b^2)/2ab}=-b/a$$
Putting it all together yields the final result
$$\bbox[5px,border:2px solid #C0A000]{I=\frac{\pi}{2a^2}}$$
