I'm trying to evaluate
$$ \frac{1}{2 \pi} \int_0^{2 \pi} \frac{e^{it}}{e^{it} - a e^{i \phi}} \ln(|e^{it} - e^{i \theta}|) dt$$
where $a \in (0, 1)$.
I'm currently doing a countour integral:
$$= \frac{1}{2 \pi} \oint \frac{z \ln(|z - e^{i \theta}|)}{z - a e^{i \phi}} \frac{dz}{i z}$$ $$= \frac{2 \pi i}{2 \pi i} \ln(|a e^{i \phi} - e^{i \theta}|)$$ $$= \ln(|a e^{i \phi} - e^{i \theta}|)$$
This is a real result (ie: there's no imaginary component). I get the same answer when I integrate numerically with some sample values, at least in the real part, but the numerical integral also has a non-zero imaginary component of roughly the same magnitude, and I don't understand where that's coming from.
Why does my analytic result disagree with my numerical result? Have I made a mistake in my contour integration?
As @Raskolnikov pointed out $\ln(|z|)$ isn't holomorphic. However, $\ln(|z|) = \frac{1}{2} (\ln(z) + \ln(\overline{z}))$. In this case, we can use that to make this to split the integral in to two holomorphic parts:
$$ \frac{1}{2 \pi} \int_0^{2 \pi} \frac{e^{it}}{e^{it} - a e^{i \phi}} \ln(|e^{it} - e^{i \theta}|) dt$$ $$ = \frac{1}{4 \pi} \int_0^{2 \pi} \frac{e^{it}}{e^{it} - a e^{i \phi}} \ln(e^{it} - e^{i \theta}) dt + \frac{1}{4 \pi} \int_0^{2 \pi} \frac{e^{it}}{e^{it} - a e^{i \phi}}\ln(e^{-it} - e^{-i \theta})) dt$$ $$= \frac{1}{4 \pi i} \oint \frac{z}{z - a e^{i \phi}} \ln(z - e^{i \theta}) \frac{dz}{z} - \frac{1}{4 \pi i} \oint \frac{dz}{z (1 - a z e^{i \phi})}\ln(z - e^{-i \theta})$$ $$= \frac{2 \pi i}{4 \pi i} (\ln (a e^{i \phi} - e^{i \theta}) - \ln(-e^{-i \theta}))$$ $$= \frac{1}{2} (\ln (a e^{i \phi} - e^{i \theta}) - i (\pi - \theta))$$