calculate the Integral $ \int \ln\left(1+2a\cos x+a^2\right)dx\;,$ where $a\in \mathbb{R}.$ How can we calculate the Integral $\displaystyle \int \ln\left(1+2a\cos x+a^2\right)dx\;,$ where $a\in \mathbb{R}.$
$\bf{My\; Try::}$ Using $\displaystyle \cos (x) = \frac{e^{ix}+e^{-ix}}{2},$ we get ...
\begin{align}\displaystyle \int \ln(1+2a\cos x+a^2)dx &= \int \ln\left(1+2a\cdot \left(\frac{e^{ix}+e^{-ix}}{2}\right)+a^2\right)dx\\ &= \int \ln(1+a\cdot (e^{ix}+e^{-ix})+a^2)dx\\&=\int \ln \left((1+ae^{ix})\cdot (1+ae^{-ix})\right)dx\\ 
&= \int \ln(1+ae^{ix})dx+\int \ln(1+ae^{-ix})dx\end{align}
Now How can I solve after that
Help me
Thanks
 A: The integral
\begin{align}
I_{+} = \int \ln(1+a e^{ix}) \ dx 
\end{align}
can be evaluated by making the substitution $t = e^{ix}$ which leads to
\begin{align}
I_{+} = - i \int \frac{\ln(1+at)}{t} \ dt = \left. i Li_{2}(-a t) \right|_{t = e^{ix}} = i \ Li_{2}(-a e^{ix}), 
\end{align}
where $Li_{2}(x)$ is the dilogarithm function. In a similar manor
\begin{align}
I_{-} = \int \ln(1 + a e^{-ix}) \ dx = - i \ Li_{2}(-a e^{-ix}).
\end{align}
As stated by the author of the problem the integral in question is:
\begin{align}
\int \ln(1+2a\cos x+a^2)dx &= \int \ln\left(1+2a\cdot \left(\frac{e^{ix}+e^{-ix}}{2}\right)+a^2\right)dx\\ 
&= \int \ln(1+a\cdot (e^{ix}+e^{-ix})+a^2)dx\\
&=\int \ln \left((1+ae^{ix})\cdot (1+ae^{-ix})\right)dx\\ 
&= \int \ln(1+ae^{ix})dx+\int \ln(1+ae^{-ix})dx \\
&= i \left[ Li_{2}(-a e^{ix}) - \ Li_{2}(-a e^{-ix}) \right].
\end{align}
In series form the dilogarithm is
\begin{align}
Li_{2}(z) = \sum_{n=1}^{\infty} \frac{z^{n}}{n^{2}}
\end{align}
and leads to
\begin{align}
\int \ln(1+2a\cos x+a^2)dx &= - 2 \ \sum_{n=1}^{\infty} \frac{(-1)^{n} \ a^{n} \ \sin(nx)}{n^{2}}
\end{align}
which is valid for $|a| \leq 1$. For the case $a > 1$ the logarithm in the integral is sen as
\begin{align}
\ln(1+2a\cos x+a^2) = 2 \ln(a) + \ln\left(1 + \frac{2}{a} \cos(x) + \frac{1}{a^{2}} \right) 
\end{align}
and leads to
\begin{align}
\int \ln(1+ 2a \cos(x) + a^{2}) dx = 2 \ln(a) \ x - 2 \ \sum_{n=1}^{\infty} \frac{(-1)^{n} \ \sin(nx)}{a^{n} \ n^{2}}.
\end{align}
As an example of the use of this integral consider the case when the limits are 0 and $\pi/2$. The integral becomes
\begin{align}
\int_{0}^{\pi/2} \ln(1+2a\cos x+a^2)dx = 2a \ \sum_{n=0}^{\infty} \frac{ (-1)^{n} \ a^{2n} }{(2n+1)^{2}}.
\end{align}
For the case of $a = 1$ this leads to the known integral value
\begin{align}
\int_{0}^{\pi/4} \ln(\cos(x)) \ dx = \frac{\textbf{G}}{2} - \frac{\pi}{2} \ \ln(2)
\end{align}
where $\textbf{G}$ is Catalan's constant. 
