# 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.

First note that by substituting $x\mapsto kx$, we get $$\int_0^\infty\log\left(\frac{x^2+2kx\cos(a)+k^2}{x^2+2kx\cos(b)+k^2}\right)\frac{\mathrm{d}x}{x} =\int_0^\infty\log\left(\frac{x^2+2x\cos(a)+1}{x^2+2x\cos(b)+1}\right)\frac{\mathrm{d}x}{x}$$ Let $u=\frac{x+\cos(a)}{\sin(a)}$. Then \begin{align} \frac{\mathrm{d}}{\mathrm{d}a}\int_0^\infty\log\left(\frac{x^2+2x\cos(a)+1}{x^2+2x+1}\right)\frac{\mathrm{d}x}{x} &=-2\int_0^\infty\frac{\sin(a)}{x^2+2x\cos(a)+1}\,\mathrm{d}x\\ &=-2\int_0^\infty\frac{\sin(a)}{(x+\cos(a))^2+\sin^2(a)}\,\mathrm{d}x\\ &=-\frac2{\sin(a)}\int_0^\infty\frac1{\frac{(x+\cos(a))^2}{\sin^2(a)}+1}\,\mathrm{d}x\\ &=-2\int_{\cot(a)}^\infty\frac1{u^2+1}\,\mathrm{d}u\\[9pt] &=-2a \end{align} Integrating in $a$ gives $$\int_0^\infty\log\left(\frac{x^2+2x\cos(a)+1}{x^2+2x+1}\right)\frac{\mathrm{d}x}{x} =-a^2$$ Therefore, by subtraction, $$\int_0^\infty\log\left(\frac{x^2+2kx\cos(a)+k^2}{x^2+2kx\cos(b)+k^2}\right)\frac{\mathrm{d}x}{x} =b^2-a^2$$

• Hhmmm, your answer gives me a new idea to evaluate this integral. (+1) – Venus Dec 15 '14 at 17:14
• Brilliant ! :-$)$ – Lucian Dec 15 '14 at 21:14

\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}

• I see that you've encapsulated the differentiation in a double integral instead of integrating twice. – robjohn Dec 15 '14 at 17:49
• @robjohn Yes. So, I didn't need to work twice. But my answer is inspired by your answer. Thanks. ^^ – Venus Dec 15 '14 at 17:51

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}.$$

• Thank you very much for helping me again, (+1). Anyway, Hatsune Miku looks very kawaii with that hat ^^ – Venus Dec 16 '14 at 5:26
• @Venus, thank you! I tried many ways until the hat fits her perfectly. Your compliment rewards my effort :) – Sangchul Lee Dec 16 '14 at 6:41

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 .$$

• Very nice approach, (+1). Thanks for giving the nice Fouries series. – Venus Dec 16 '14 at 5:29
• @Venus Thanks. I had accidentally put the parameter $a$ in the numerator and the parameter $b$ in the denominator. – Random Variable Dec 16 '14 at 8:39
• How do you prove that Fourier series? – clathratus Feb 13 at 1:06


\begin{align}&\overbrace{\color{#66f}{\large\int_{0}^{\infty} \ln\pars{x^{2} + 2kx\cos\pars{b} + k^{2}\over x^{2} + 2kx\cos\pars{a} + k^2}\,{\dd x \over x}}} ^{\dsc{x \over k}\ \ds{\mapsto}\ \dsc{x}} \\[5mm]&=\int_{0}^{\infty} \ln\pars{x^{2} + 2x\cos\pars{b} + 1\over x^{2} + 2x\cos\pars{a} + 1} \,{\dd x \over x} =\lim_{R\ \to\ \infty}\bracks{\fermi\pars{a,R} - \fermi\pars{b,R}} \\[5mm]&\mbox{where}\ \begin{array}{|c|}\hline\\ \ \fermi\pars{\mu,R}\equiv \int_{0}^{R}\ln\pars{x} {2x + 2\cos\pars{\mu}\over x^{2} + 2x\cos\pars{\mu} + 1}\,\dd x\,,\quad 0 < \mu < \pi\ \\ \\ \hline \end{array}\qquad\qquad\quad\pars{1} \end{align}

Note that $\ds{r_{-} \equiv \exp\pars{\bracks{\pi - \mu}\ic}}$ and $\ds{r_{+} \equiv \exp\pars{\bracks{\pi + \mu}\ic}}$ are the roots of $\ds{x^{2} + 2x\cos\pars{\mu} + 1 = 0}$ such that $\ds{\pars{~\mbox{with}\ R > 1~}}$:

\begin{align}&\dsc{\int_{0}^{R}\ln^{2}\pars{x} {x + \cos\pars{\mu}\over x^{2} + 2x\cos\pars{\mu} + 1}\,\dd x} \\[5mm]&=2\pi\ic\bracks{\half\,\ln^{2}\pars{r_{-}} + \half\,\ln^{2}\pars{r_{+}}} -\int_{R}^{0}\bracks{\ln\pars{x} + 2\pi\ic}^{2} {x + \cos\pars{\mu}\over x^{2} + 2x\cos\pars{\mu} + 1}\,\dd x \\[5mm]&=\pi\ic\bracks{-\pars{\pi - \mu}^{2} - \pars{\pi + \mu}^{2}} +\dsc{\int_{0}^{R}\ln^{2}\pars{x} {x + \cos\pars{\mu}\over x^{2} + 2x\cos\pars{\mu} + 1}\,\dd x} \\[5mm]&+2\pi\ic\ \overbrace{\int_{0}^{R}\ln\pars{x} {2x + 2\cos\pars{\mu}\over x^{2} + 2x\cos\pars{\mu} + 1}\,\dd x} ^{\dsc{\fermi\pars{\mu,R}}}\ +\ \pars{2\pi\ic}^{2}\int_{0}^{R} {x + \cos\pars{\mu} \over x^{2} + 2x\cos\pars{\mu} + 1}\,\dd x \\[5mm]&-{\mathfrak C}\pars{R,\mu} \end{align} where $\ds{\left.{\mathfrak C}\pars{R,\mu} \equiv\oint\ln^{2}\pars{z} {z + \cos\pars{\mu}\over z^{2} + 2z\cos\pars{\mu} + 1}\,\dd z\,\right\vert _{z\ \equiv\ R\expo{\ic\theta}\,,\ 0\ <\ \theta\ <\ 2\pi}}$

This expression leads to: \begin{align} 0&=-2\pi\ic\pars{\pi^{2} + \mu^{2}} + 2\pi\ic\int_{0}^{R}\ln\pars{x} {2x + 2\cos\pars{\mu}\over x^{2} + 2x\cos\pars{\mu} + 1}\,\dd x \\[5mm]&+\pars{2\pi\ic}^{2}\int_{\cos\pars{\mu}}^{R + \cos\pars{\mu}} {x \over x^{2} + \sin^{2}\pars{\mu}}\,\dd x - {\mathfrak C}\pars{R,\mu} \end{align}

and \begin{align} \fermi\pars{\mu,R}&=\int_{0}^{R}\ln\pars{x} {2x + 2\cos\pars{\mu}\over x^{2} + 2x\cos\pars{\mu} + 1}\,\dd x \\[5mm]&=\pi^{2} + \mu^{2} -\pi\ic\ln\pars{\bracks{R + \cos\pars{\mu}}^{2} + \sin^{2}\pars{\mu}} + {{\mathfrak C}\pars{R,\mu} \over 2\pi\ic} \end{align}

In the $\ds{R \to \infty}$ we'll have: \begin{align} \lim_{R \to\ \infty}\bracks{\fermi\pars{a,R} - \fermi\pars{b,R}} &=a^{2} - b^{2} \end{align}

such that expression $\pars{1}$ is reduced to: \begin{align}&\color{#66f}{\large\int_{0}^{\infty} \ln\pars{x^{2} + 2kx\cos\pars{b} + k^{2}\over x^{2} + 2kx\cos\pars{a} + k^2}\,{\dd x \over x}} =\color{#66f}{\large a^{2} - b^{2}} \end{align}

• Thanks for your answer Felix, (+1). It's good to have many different ways to evaluate this integral. – Venus Dec 16 '14 at 6:46
• @Venus You're welcome. I left some details that you can recover. I did it because it was growing out of my energy. – Felix Marin Dec 16 '14 at 7:10
• Thanks for the details Felix, you're so kind. I hope I can learn some complex analysis techniques from your answer. Anyway, where's your hat? You should wear it. :-) – Venus Dec 16 '14 at 8:19