How do I calculate the following integral containing a logarithm amplitude and an exponential? I am interested in the evaluation of the following integral:
$$
\int_0^{2\pi}e^{in\theta}\ln|a+be^{i\theta}| \, d\theta
$$
where $n$ is an integer and $a$ and $b$ are complex numbers such that $|a|>|b|$ (so the logarithm doesn't have a singularity). When $n=0$, I can easily turn the integral into a contour integral around the unit circle by writing $\ln|a+be^{i\theta}|=\operatorname{Re}(\ln(a+be^{i\theta}))$, taking the real part out of the integral and then substituting $z=e^{i\theta}$. Doing this gives the answer $2\pi \ln|a|$, which agrees with NIntegrate in Mathematica.
I can't see how the same trick can deal with non-zero integer values of $n$. However, I can begin to see through NIntegrate that, for example, when $n=1$, the integral is probably $(\frac{b}{a})^{*}\pi$, but I don't see how to get this.
Thanks in advance for any help.
 A: I'll sketch out a way forward and leave the details to the reader.
Let's begin by writing $a=|a|e^{i\theta_a}$ and $b=|b|e^{i\theta_b}$. Then, we have
$$|a+be^{i\theta}|=|a|\left|1+\frac{|b|}{|a|}e^{i(\theta+\theta_b-\theta_a)}\right|\tag1$$
Exploiting the $2\pi$-periodicity of the integrand reveals
$$\begin{align}
\int_0^{2\pi}e^{in\theta} \log\left(|a+be^{i\theta}|\right)\,d\theta&=e^{n(\theta_a-\theta_b)}\int_0^{2\pi}e^{in\theta} \log\left(|1+ce^{i\theta}|\right)\,d\theta\\\\
&=\frac12e^{n(\theta_a-\theta_b)}\int_0^{2\pi}e^{in\theta} \log\left(1+c^2+2c\cos(\theta)\right)\,d\theta\tag2
\end{align}$$
where $c=|b/a|<1$.
We can write the integral on the right-hand side of $(2)$ as
$$\int_0^{2\pi}e^{in\theta} \log\left(1+c^2+2c\cos(\theta)\right)\,d\theta=\int_0^c \int_0^{2\pi}\frac{e^{in\theta}(2x+2\cos(\theta))}{1+x^2+2x\cos(\theta)}\,d\theta\,dx\tag3$$
The interior integral on the right-hand side of $(3)$ can be evaluated using contour integration.  That is, we can write
$$\int_0^{2\pi}\frac{e^{in\theta}(2x+2\cos(\theta))}{1+x^2+2x\cos(\theta)}\,d\theta=2\oint_{|z|=1}\frac{z^n\left(x+\frac{z+z^{-1}}{2}\right)}{1+x^2+x(z+z^{-1})}\frac1{iz}\,dz\tag4$$
Now evaluate the contour integral in $(4)$ and then integrate with respect to $x$.
