Integrate $\int_0^{2\pi}\frac{\ln(a + b\cos x)}{c + d\cos x} dx$, Residue theorem I have recently been given a challenge problem in my Complex Analysis class. Suppose $a > b > 0$ and $c > d > 0$. Evaluate
$$\int_0^{2\pi} \frac{\ln(a + b\cos x)}{c + d\cos x} dx$$
using the Residue Theorem. Unfortunately, I don't even know where to begin with this one. I have managed to solve the integral where the integrand is
$$\frac{a + b\cos x}{c + d\cos x}$$
where the contour I used was the usual a square but I'm not sure whether that can be applied here. If anyone could provide any assistance, that would be greatly appreciated!
 A: Choose $r, s \in (0, 1)$ so that
$$\frac{b}{a} = \frac{2r}{1+r^2}, \qquad \frac{d}{c} = \frac{2s}{1+s^2}.$$
Then
$$ \left| (1 - re^{i\theta})(1 - re^{-i\theta}) \right| = 1 + r^2 - 2r\cos\theta. $$
From this, we get
\begin{align*}
\log(1 + r^2 - 2r\cos\theta)
&= \log\left|1 - re^{i\theta}\right| + \log\left|1 - re^{-i\theta}\right| \\
&= \operatorname{Re}\left[ \log\left(1 - re^{i\theta}\right) + \log\left(1 - re^{-i\theta}\right) \right] \\
&= 2 \operatorname{Re}\left[ \log\left(1 - re^{i\theta}\right) \right].
\end{align*}
This, together with $z^2 - 2(c/d)z + 1 = (z - s)(z - s^{-1})$, shows that
\begin{align*}
\int_{0}^{2\pi} \frac{\log(a + b\cos\theta)}{c+d\cos\theta} \, \mathrm{d}\theta
&= \int_{0}^{2\pi} \frac{\log(a - b\cos\theta)}{c-d\cos\theta} \, \mathrm{d}\theta \\
&= \int_{0}^{2\pi} \frac{\log\bigl(\frac{a}{1+r^2}\bigr) + \log(1 + r^2 - 2r\cos\theta)}{c-d\cos\theta} \, \mathrm{d}\theta \\
&= \operatorname{Re}\left[ \int_{0}^{2\pi} \frac{\log\bigl(\frac{a}{1+r^2}\bigr) + 2\log(1 - re^{i\theta})}{c-d\cos\theta} \, \mathrm{d}\theta \right] \\
&= \operatorname{Re}\left[ \frac{2i}{d} \int_{|z| = 1} \frac{\log\bigl(\frac{a}{1+r^2}\bigr) + 2\log(1 - rz)}{z^2-2(c/d)z+1} \, \mathrm{d}z \right] \tag{$z=e^{i\theta}$} \\
&= \operatorname{Re}\left[ -\frac{4\pi}{d} \, \underset{z=s}{\mathrm{Res}} \, \frac{\log\bigl(\frac{a}{1+r^2}\bigr) - 2\log(1 - rz)}{z^2-2(c/d)z+1} \right].
\end{align*}
Computing the residue and simplifying, we get
\begin{align*}
&\int_{0}^{2\pi} \frac{\log(a + b\cos\theta)}{c+d\cos\theta} \, \mathrm{d}\theta \\
&= \frac{2\pi}{\sqrt{c^2-d^2}} \left[ \log\left(\frac{a+\sqrt{a^2-b^2}}{2}\right) + 2 \log\left(1 - \frac{a-\sqrt{a^2-b^2}}{b} \cdot \frac{c-\sqrt{c^2-d^2}}{d}\right)\right].
\end{align*}
