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.

\begin{align}
\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{1}{x}\int_a^b  \frac{\mathrm d}{\mathrm dy}\ln \left(x^2+2kx\cos y+k^2\right) \;\mathrm dy\,\mathrm dx\\[10pt]
&=-\int_0^\infty\frac{1}{x}\int_a^b  \frac{2kx\sin y}{x^2+2kx\cos y+k^2} \;\mathrm dy\,\mathrm dx\\[10pt]
&=2k\int_b^a\sin y\int_0^\infty  \frac{\mathrm dx}{x^2+2kx\cos y+k^2} \;\mathrm dy\\[10pt]
&=2k\int_b^a\sin y\int_0^\infty  \frac{\mathrm dx}{\left(x+k\cos y\right)^2+k^2-k^2\cos^2y} \;\mathrm dy\\[10pt]
&=2k\int_b^a\sin y\underbrace{\int_0^\infty  \frac{\mathrm dx}{\left(x+k\cos y\right)^2+k^2\sin^2y}}_{\large\color{blue}{(k\sin y)\, u\,=\,x+k\cos y}} \;\mathrm dy\\[10pt]
&=2\int_b^a\int_{\cot y}^\infty  \frac{\mathrm du}{u^2+1} \;\mathrm dy\\[10pt]
&=2\int_b^a\left(\frac{\pi}{2}-\arctan\left(\cot y\right)\right)\;\mathrm dy\\[10pt]
&=2\int_b^ay\;\mathrm dy\\[10pt]
&=\bbox[8pt,border:3px #FF69B4 solid]{\color{red}{\large a^2-b^2}}
\end{align}
