TITLE: Calculation of $\int_0^{\pi} \frac{\sin^2 x}{a^2+b^2-2ab \cos x}\mathrm dx$
QUESTION [10 upvotes]: Calculate the definite integral
$$
I=\int_0^{\pi} \frac{\sin^2 x}{a^2+b^2-2ab \cos x}\;\mathrm dx
$$
given that $a>b>0$.

My Attempt:
If we replace $x$ by $C$, then
$$
I = \int_{0}^{\pi}\frac{\sin^2 C}{a^2+b^2-2ab\cos C}\;\mathrm dC
$$
Now we can use the Cosine Formula ($A+B+C=\pi$). Applying the formula gives
$$
\begin{align}
\cos C &= \frac{a^2+b^2-c^2}{2ab}\\
a^2+b^2-2ab\cos C &= c^2
\end{align}
$$
From here we can use the formula $\dfrac{\sin A}{a} = \dfrac{\sin B}{b} = \dfrac{\sin C}{c}$ to transform the integral to
$$
\begin{align}
I &= \int_{0}^{\pi}\frac{\sin^2 C}{c^2}\;\mathrm dC\\
&= \int_{0}^{\pi}\frac{\sin^2A}{a^2}\;\mathrm dC\\
&= \int_{0}^{\pi}\frac{\sin^2 B}{b^2}\;\mathrm dC
\end{align}
$$
Is my process right? If not, how can I calculate the above integral?

REPLY [2 votes]: Let $p=a^2+b^2,q=2ab$ so that $p^2-q^2=(a^2-b^2)^2$ and the integrand can be rewritten as $$\frac{\sin^2x}{p-q\cos x} = \frac{1}{q}\left(\cos x+\frac{p}{q}+\frac{1}{q}\cdot\frac{q^2-p^2}{p-q\cos x} \right) $$ and thus the desired integral is equal to $$0+\frac{p\pi}{q^2}+\frac{q^2-p^2}{q^2}\int_{0}^{\pi}\frac{dx}{p-q\cos x} $$ The integral above is famously equal to $\pi/\sqrt{p^2-q^2}$ and hence the value of the integral in question is equal to $$\frac{\pi} {q^2}\cdot(p-\sqrt{p^2-q^2})=\frac{\pi}{2a^2}$$