<s>[INST] Closed form of $\int_0^\infty \ln \left( \frac{x^2+2kx\cos b+k^2}{x^2+2kx\cos a+k^2}\right) \;\frac{\mathrm dx}{x}$ Today I discussed the following integral in the chat room

$$\int_0^\infty  \ln \left( \frac{x^2+2kx\cos b+k^2}{x^2+2kx\cos a+k^2}\right) \;\frac{\mathrm dx}{x}$$
  where $0\leq a, b\leq \pi$ and $k>0$.

Some users suggested me that I can use Frullani's theorem:
$$\int_0^\infty \frac{f(ax) - f(bx)}{x} = \big[f(0) - f(\infty)\big]\ln \left(\frac ab\right)$$
So I tried to work with that way.
\begin{align}   I&=\int_0^\infty  \ln \left( \frac{x^2+2kx\cos b+k^2}{x^2+2kx\cos a+k^2}\right) \;\frac{\mathrm dx}{x}\\   &=\int_0^\infty \frac{\ln \left( x^2+2kx\cos b+k^2\right)-\ln \left( x^2+2kx\cos a+k^2\right)}{x}\mathrm dx\tag{1}\\   &=\int_0^\infty \frac{\ln \left( 1+\dfrac{2k\cos b}{x}+\dfrac{k^2}{x^2}\right)-\ln \left( 1+\dfrac{2k\cos a}{x}+\dfrac{k^2}{x^2}\right)}{x}\mathrm dx\tag{2}\\   \end{align}
The issue arose from $(1)$ because $f(\infty)$ diverges and the same issue arose from $(2)$ because $f(0)$ diverges. I then tried to use D.U.I.S. by differentiating w.r.t. $k$, but it seemed no hope because WolframAlpha gave me this horrible form. Any idea? Any help would be appreciated. Thanks in advance.
 [/INST] Another approach is to use the Fourier series $$\sum_{k=1}^{\infty}\frac{x^{k} \cos(ka)}{k} = - \frac{1}{2} \log \left(x^{2} - 2 x \cos(a)  +1 \right) \ , \ |x| <1 $$ which can be derived from the Maclaurin series of $\log(1-z)$ by replacing $z$ with $xe^{ia}$ and equating the real parts on both sides.
$$ \begin{align} \int_0^\infty\log\left(\frac{x^2+2kx\cos(b)+k^2}{x^2+2kx\cos(a)+k^2}\right)\frac{dx}{x}
&=\int_0^\infty\log\left(\frac{u^2+2u\cos(b)+1}{u^2+2u\cos(a)+1}\right)\frac{du}{u} \tag{1} \\ &= 2 \int_{0}^{1} \tag{2} \log\left(\frac{u^2+2u\cos(b)+1}{u^2+2u\cos(a)+1}\right)\frac{du}{u} \\ &= 4 \int_{0}^{1} \frac{1}{u} \sum_{k=1}^{\infty} (-u)^{k} \frac{\cos(ka) - \cos(kb)}{k} \\ &= 4 \sum_{k=1}^{\infty} (-1)^{k} \frac{\cos(ka) -\cos(kb)}{k} \int_{0}^{1} u^{k-1} \ du \\ &= 4 \sum_{k=1}^{\infty} (-1)^{k} \frac{\cos(ka) - \cos(kb)}{k^{2}}  \\ &= 4 \left(\frac{a^{2}}{4} - \frac{b^{2}}{4} \right) \tag{3} \\ &= a^{2}- b^{2} \end{align} $$
$ $
$(1)$  Let $ \displaystyle u= \frac{x}{k}.$
$(2)$ Separate the integral into two integrals, namely one over the interval $(0,1)$ and one over the interval $(1, \infty)$, and replace $u$ with $\frac{1}{u}$ in the second integral. 
$(3)$  By integrating the Fourier series $ \displaystyle \sum_{k=1}^{\infty} (-1)^{k} \frac{\sin(ka)}{k} = - \frac{a}{2} \ , \ |a| < \pi$, we get $$ \sum_{k=1}^{\infty} (-1)^{k} \frac{\cos(ka)}{k^{2}} = \frac{a^{2}}{4} - \frac{\pi^{2}}{12} \ , \  |a| < \pi .$$
</s>