I'm trying to evaluate
$$\int_0^{2\pi}e^{2it}\ln(a^2-2a \cos(t) + 1)dt$$
for $a \in (0, 1)$.
I keep getting different answers depending on the method. First, if I split up the integrals in to real and imaginary parts I get:
$$ = \int_0^{2\pi} (\cos(2t) + i \sin(2t)) \ln(a^2-2a \cos(t) + 1)dt\\ = \int_0^{2\pi} \cos(2t) \ln(a^2-2a \cos(t) + 1)dt + i \int_0^{2\pi} \sin(2t) \ln(a^2-2a \cos(t) + 1)dt\\ = - \frac{1}{4 a^2} \left[\begin{array}& (a^4 + 1) t \\ - 2 (a^4 - 1) \arctan \frac{(a + 1) \tan(t/2)}{a - 1} \\ + 2 (a^3 + a) \sin(t) \\ + a^2 \sin(2 t) (1 - 2 \sin(2 t) \ln(a^2 - 2 a \cos(t) + 1)) \end{array} \right]_0^{2\pi} + i * 0 \\ = - \pi \frac{a^4 + 1}{2 a^2}$$
Where I got $\int \cos(2t) \ln(a^2-2a \cos(t) + 1) dt$ from Wolfram Alpha. This other online integral calculator gives a different but equivalent antiderivative.
Second, if I do a contour integral:
$$ = \int_0^{2\pi} e^{2it} \ln((1-ae^{it}) (1 - a e^{-it})) dt \\ = \int_0^{2\pi} e^{2it} (\ln(1-ae^{it}) + \ln(1 - a e^{-it})) dt \\ = \int_0^{2\pi} e^{2it} \ln(1-ae^{it}) + \int_0^{2\pi} e^{2it} \ln(1 - a e^{-it}) dt \\ = \oint \frac{z \ln(1-az)}{i}dz - \oint \frac{\ln(1 - a z)}{iz^3} dz \\ = 2 \pi i (0 - \frac{a^2}{2i}) \\ = -\pi a^2 $$
Third, if I ask an online integral calculator, I just get 0.
I have no idea which, if any, answer is correct, or what mistakes I made in any of the methods. Any help would be appreciated.
HINT.
Your second approach is correct. In the first one the expression used for the antiderivative is discontinuous at the point $t=\pi$ if the standard definition of the real $\arctan x$ function is used. To avoid this issue use the symmetry and calculate the integral as: $$ 2\int_0^{\pi}\cos(2t)\ln(a^2-2a \cos(t) + 1)dt. $$