What is the solution of this definite integral: $\int_{0}^{2\pi} \ln\big(C-D\cos(f)\big)\cos(nf)df$ I encountered this integral in my calculations:
$$\int_{0}^{2\pi} \ln\big(C-D\cos(f)\big)\cos(nf)df$$
Here, $n$ is a natural number, $C, D$ are constants, such that $C\gt D$.
I tried to find solution in Table of integrals,series and products and by using Wolfram mathematica, but I have not managed to find it.

For $r<1$, we have
$$ \log{(1+r^2-2r\cos{\theta})} = \log{(1-re^{i\theta})(1-re^{-i\theta})} \\
= \log{(1-re^{i\theta})}+\log{(1-re^{-i\theta})} \\
= -\sum_{k=1}^{\infty} \frac{1}{k}r^k (e^{ik\theta}+e^{-ik\theta}) \\
= -2\sum_{k=1}^{\infty} \frac{r^k}{k} \cos{k\theta}, $$
provided that we choose all the logarithms to have value $0$ when their argument is $1$, i.e. $r=0$. Thus
$$ \int_0^{2\pi} \cos{n\theta}\log{(1+r^2-2r\cos{\theta})} \, d\theta = -2\sum_{k=1}^{\infty} \frac{r^k}{k} \int_0^{2\pi} \cos{k\theta}\cos{n\theta} \, d\theta = -2\pi\frac{r^n}{n}, $$
using that the series is uniformly convergent.

How does this relate to your integral? We can write the integrand as $\log{(1+r^2)}+\log{(1-\frac{2r}{1+r^2} \cos{\theta})}$ without affecting the result for $n \neq 0$. So if we split $\log{(C-D\cos{\theta})}=\log{C}+\log{(1-(D/C)\cos{\theta})}$, we can take $C/D = 2r/(1+r^2) $, and solving this gives
$$ r = \frac{1-\sqrt{1-(D/C)^2}}{D/C}, $$
since we need $r<1$. Thus
$$ \log{(C-D\cos{\theta})} = \log{C} + \log{1-(D/C)\cos{\theta}} = \log{C}-\log{(1+r^2)} +\log{(1+r^2-2r\cos{\theta})} \\
= \log{\left( \frac{C(D/C)^2}{2(1-\sqrt{1-(D/C)^2})} \right)} + \log{(1+r^2-2r\cos{\theta})}, $$
which we can integrate. We therefore conclude that
$$ \int_0^{2\pi} \cos{n\theta}\log{(C-D\cos{\theta})} \, d\theta = \begin{cases} 
2\pi \log{\left( \frac{C(D/C)^2}{2(1-\sqrt{1-(D/C)^2})} \right)} & n=0 \\
-\frac{2\pi}{n}  \left( \frac{1-\sqrt{1-(D/C)^2}}{D/C} \right)^n& n \in \mathbb{Z} \setminus \{0\}.
 \end{cases} $$
