Evaluate $\int_0^{\pi} \frac{\sin^2 \theta}{(1-2a\cos\theta+a^2)(1-2b\cos\theta+b^2)}\mathrm{d\theta}, \space 0Evaluate by complex methods
$$\int_0^{\pi} \frac{\sin^2 \theta}{(1-2a\cos\theta+a^2)(1-2b\cos\theta+b^2)}\mathrm{d\theta}, \space 0<a<b<1$$
Sis.

$\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\on}[1]{\operatorname{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
\begin{align}
&\bbox[5px,#ffd]{\left.\int_{0}^{\pi}{\sin^{2}\pars{\theta} \over \bracks{1 - 2a\cos\pars{\theta} + a^{2}}
\bracks{1 - 2b\cos\pars{\theta} + b^{2}}}\,\dd\theta
\,\right\vert_{\, 0\ <\ a\ <\ b\ <\ 1}}
\\[5mm] = &\
{1 \over 2}
\int_{-\pi}^{\pi}{\pars{\expo{\ic\theta} - \expo{-\ic\theta}}^{2}/\pars{-4} \over
\pars{a - \expo{\ic\theta}}\pars{a - \expo{-\ic\theta}}
\pars{b - \expo{\ic\theta}}
\pars{b - \expo{-\ic\theta}}}\,\dd\theta
\\[5mm] = &\
-{1 \over 8}\,\Re
\int_{-\pi}^{\pi}{\pars{z - z^{-1}}^{2} \over
\pars{a - z}\pars{a - z^{-1}}
\pars{b - z}
\pars{b - z^{-1}}}\,{\dd z \over \ic z}
\\[5mm] = &\
-{1 \over 8ab}\,\Im
\int_{-\pi}^{\pi}{\pars{z^{2} - 1}^{2} \over
z\pars{z - a}\pars{z - a^{-1}}
\pars{z - b}
\pars{z - b^{-1}}}\,\dd z
\end{align}
The integrand has simple poles at $\ds{z \in \braces{0,a,b}}$ with
$$
\left\{\begin{array}{rcl}
\ds{\on{Res}_{\, z\ =\ 0}} & \ds{=} & \ds{\phantom{-}1}
\\[1mm]
\ds{\on{Res}_{\, z\ =\ a}} & \ds{=} &
\ds{-{\pars{1 - a^{2}}b \over \pars{b - a}\pars{1 - ab}}}
\\[1mm]
\ds{\on{Res}_{\, z\ =\ b}} & \ds{=} &
\ds{\phantom{-}
{a\pars{1 - b^{2}} \over \pars{b - a}\pars{1 - ab}}}
\end{array}\right.
$$
Then,
\begin{align}
&\bbox[5px,#ffd]{\left.\int_{0}^{\pi}{\sin^{2}\pars{\theta} \over \bracks{1 - 2a\cos\pars{\theta} + a^{2}}
\bracks{1 - 2b\cos\pars{\theta} + b^{2}}}\,\dd\theta
\,\right\vert_{\, 0\ <\ a\ <\ b\ <\ 1}}
\\[5mm] = &\
-{1 \over 8ab}\Im\bracks{2\pi\ic\pars{\on{Res}_{\, z\ =\ 0}\ +\
\on{Res}_{\, z\ =\ a}\ +\ \on{Res}_{\, z\ =\ b}}}
\\[5mm] = &\
\bbx{\pi/2 \over 1 - ab} \\ &
\end{align}
