<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] Here is a complex-analytic method: Notice that
$$ \int_{0}^{\infty} \log\left( \frac{x^{2} + 2x\cos b + 1}{x^{2} + 2x\cos a + 1} \right) \frac{dx}{x}
= 2 \int_{0}^{\infty} \Re \frac{\log(1 + e^{ib}x) - \log(1 + e^{ia}x)}{x} \, dx. \tag{1} $$
Let $R$ be a positive large number. Then the function $z \mapsto \log(1+z)/z$ is analytic on $\Bbb{C} \setminus (-\infty, 1]$ with the standard branch cut and we get
\begin{align*}
\int_{0}^{R} \frac{\log(1 + e^{ib}x)}{x} \, dx
&=\int_{0}^{Re^{ib}} \frac{\log(1 + z)}{z} \, dz \qquad (z = e^{ib}x) \\
&= \int_{0}^{R} \frac{\log(1 + z)}{z} \, dz + \int_{R}^{Re^{ib}} \frac{\log(1 + z)}{z} \, dz \\
&= \int_{0}^{R} \frac{\log(1 + z)}{z} \, dz + i \int_{0}^{b} \log(1 + Re^{i\theta}) \, d\theta, \quad (z=Re^{i\theta})
\end{align*}
and likewise for the integral with $b$ replaced by $a$. This shows that
$$ \int_{0}^{R} \frac{\log(1 + e^{ib}x) - \log(1 + e^{ia}x)}{x} \, dx
= i \int_{a}^{b} \log(1 + Re^{i\theta}) \, d\theta. $$
Multiplying by 2 and taking real part, we get
$$ 2 \int_{0}^{R} \Re \frac{\log(1 + e^{ib}x) - \log(1 + e^{ia}x)}{x} \, dx
= - 2 \Im \int_{a}^{b} \log(R^{-1} + e^{i\theta}) \, d\theta. $$
(Here we exploited the fact that $\log R$ is real.) Taking $R \to \infty$, in view of the identity $\text{(1)}$ it follows that
$$ \int_{0}^{\infty} \log\left( \frac{x^{2} + 2x\cos b + 1}{x^{2} + 2x\cos a + 1} \right) \frac{dx}{x}
= - \int_{a}^{b} 2\theta \, d\theta
= a^{2} - b^{2}. $$
</s>