Imaginary part of $\int_{0}^{\pi/2} \frac{x^2}{x^2+\log ^2(-2\cos x)} \:\mathrm{d}x$ and $\int_{0}^{\pi/2} \frac{\log \cos x}{x^2}\:\mathrm{d}x$

This is an extremely interesting question (well, at least to me), I wonder why it had laid in oblivion without any answer for three years.


I will first fix some notations $$I = \int_0^{\pi /2} {\frac{{{x^2}}}{{{x^2} + {{\left[ {\ln (2\cos x) - \pi i} \right]}^2}}}dx} $$ Note that $\Im I$ is the negative of that in the question. thus we have to prove that

$$\tag{*} \Im I = \frac{\ln 2}{4} - \frac{\pi^2}{16} - \frac{\pi}{8}\int_0^{\pi/2} \frac{\ln(\cos x)}{x^2} dx$$

Denote

  • $\log_1 z$ as the branch of logarithm, with $\log_1 1 = 0$ and the branch cut depicted below
  • $\log_2 z$ as the branch of logarithm, with $\log_2 1 = 0$ and the branch cut depicted below
  • $\ln z$ as the principal branch of logarithm.

Branch cuts

The blue line depicted is a semicircle. Strictly speaking, we have to extend the cut of $\log_1 z$ to infinity, however, this is of no importance to us.

We also define $\text{si}(x)$ which will be used later: $$\text{si}(x) = -\int_x^\infty \frac{\sin z}{z} dz $$


1. Reducing the integral via contour integration

The function $z\mapsto -1-z^{-1}$ maps the cut of $\log_1 z$ to the cut of $\log_2 z$. Denote $$f(z) = \frac{{{{\log }_1}z}}{{z{{\log }_2}( - 1 - {z^{ - 1}})}}$$ and we integrate it along the following contour: Contour

note that $f(z)$ is meromorphic in its interior, with a pole at $-1/2$. The blue curve is parametrized by $$z = \frac{{ - 1 + ui}}{{1 + {u^2}}}\qquad 0 < u < \infty \qquad dz = \frac{{i + 2u - {u^2}i}}{{{{(1 + {u^2})}^2}}}du$$ Along $\gamma_1$: $$\begin{aligned}\int_{{\gamma _1}} {f(z)dz} &= \int_{ - \pi }^\pi {\frac{{i{e^{ix}}{{\log }_1}({e^{ix}})}}{{{e^{ix}}{{\log }_2}( - 1 - {e^{ - ix}})}}dx} \\ &= - 4\int_{ - \pi /2}^{\pi /2} {\frac{x}{{{{\log }_2}( - 1 - {e^{ - 2ix}})}}dx} \\ &= - 4\int_0^{\pi /2} {\left[ {\frac{x}{{{{\log }_2}( - 1 - {e^{ - 2ix}})}} - \frac{x}{{{{\log }_2}( - 1 - {e^{2ix}})}}} \right]dx} \\ &= - 8i\int_0^{\pi /2} {\frac{{{x^2}}}{{{x^2} + {{\log }_2}^2( - 2\cos x)}}dx} = -8i I\end{aligned}$$ Along $\gamma_2$: $$\begin{aligned}\int_{{\gamma _2}} {f(z)dz} &= \int_{{\gamma _2}} {\frac{{\ln ( - z) + \pi i}}{{z\left[ {\ln ( - i( - 1 - {z^{ - 1}})) - \frac{{3\pi i}}{2}} \right]}}dz} \\ &= \int_0^R {\frac{{ - i - u}}{{1 + {u^2}}}\frac{{\ln \left( {\frac{{1 - ui}}{{1 + {u^2}}}} \right) + \pi i}}{{\ln u - \frac{{3\pi i}}{2}}}du} \end{aligned} $$ Along $\gamma_3$: $$\begin{aligned}\int_{{\gamma _3}} {f(z)dz} &= \int_{{\gamma _3}} {\frac{{\ln ( - z) - \pi i}}{{z\left[ {\ln ( - i( - 1 - {z^{ - 1}})) + \frac{{\pi i}}{2}} \right]}}dz} \\ &= - \int_0^R {\frac{{ - i - u}}{{1 + {u^2}}}\frac{{\ln \left( {\frac{{1 - ui}}{{1 + {u^2}}}} \right) - \pi i}}{{\ln u + \frac{{\pi i}}{2}}}du} \end{aligned}$$ where $R$ is a very large positive number (the integral diverges if $R$ is replaced by $\infty$). However, the combined of $\gamma_2,\gamma_3$ converges: $$\int_{{\gamma _2}} {f(z)dz} + \int_{{\gamma _3}} {f(z)dz} = \int_0^\infty {\frac{{ - i - u}}{{1 + {u^2}}}\frac{{2\pi i\left[ {\ln \left( {\frac{{1 - ui}}{{1 + {u^2}}}} \right) + \ln u} \right] + {\pi ^2}}}{{(\ln u - \frac{{3\pi i}}{2})(\ln u + \frac{{\pi i}}{2})}}du} $$ For $\gamma_4$, the value is nonzero as the radius $r$ tends to $0$: $$\begin{aligned} \int_{{\gamma _4}} {f(z)dz} &= - \int_{\pi /2}^{-3\pi /2} {\frac{{ir{e^{ix}}\ln (r{e^{ix}})}}{{r{e^{ix}}\log ( - {r^{ - 1}}{e^{ - ix}} - 1)}}dx} \\ &= - i\int_{\pi /2}^{-3\pi /2} {\frac{{\ln r + ix}}{{\log ( - {r^{ - 1}}{e^{ - ix}} - 1)}}dx} \\ &= - i\int_{\pi /2}^{-3\pi /2} {\frac{{\ln r}}{{\ln r + o(1)}}dx} + o(1) = 2\pi i + o(1)\end{aligned}$$ The residue at the pole $z=-1/2$ is $(\ln 2 + \pi i)/2$. Hence $$ - 8iI + \int_0^\infty {\frac{{ - i - u}}{{1 + {u^2}}}\frac{{2\pi i\left[ {\ln \left( {\frac{{1 - ui}}{{1 + {u^2}}}} \right) + \ln u} \right] + {\pi ^2}}}{{(\ln u - \frac{{3\pi i}}{2})(\ln u + \frac{{\pi i}}{2})}}du} + 2\pi i = 2\pi i \times \frac{1}{2}(\ln 2 + \pi i)$$ This is equivalent to:

$$\tag{1} - 8I + 2\pi i\int_{ - \infty }^\infty {\frac{{\ln (i + {e^{ - x}})}}{{i + {e^{ - x}}}}\frac{1}{{(x - \frac{{3\pi i}}{2})(x + \frac{{\pi i}}{2})}}dx} = \frac{{{\pi ^2}}}{2}i + (\pi \ln 2 - \pi )$$


2. Second round of contour integration

Now we integrate the function $$\frac{{\ln (i + {e^{ - z}})}}{{i + {e^{ - z}}}}\frac{1}{{(z - \frac{{3\pi i}}{2})(z + \frac{{\pi i}}{2})}}$$ along the rectangle with vertices $\pm \infty$ and $\pm \infty + \pi i/2$, with a slight indention at $z=\pi i /2$, which is a branch point for numerator and pole for denumerator. Giving $$\tag{2} \int_{ - \infty }^\infty {\frac{{\ln (i + {e^{ - x}})}}{{i + {e^{ - x}}}}\frac{1}{{(x - \frac{{3\pi i}}{2})(x + \frac{{\pi i}}{2})}}dx} = PV\int_{ - \infty }^\infty {\frac{{\ln (i - i{e^{ - x}})}}{{i - i{e^{ - x}}}}\frac{1}{{{x^2} + {\pi ^2}}}dx} $$ Now we dismantle the Cauchy principal value, let $r$ be a small positive number, we have $$\begin{aligned} (\int_{-\infty}^{-r} + \int_r^{\infty}) {\frac{{\ln (i - i{e^{ - x}})}}{{i - i{e^{ - x}}}}\frac{1}{{{x^2} + {\pi ^2}}}} &= \int_r^\infty {\frac{1}{{{z^2} + {\pi ^2}}}\left[ {\frac{{\ln (i - i{e^{ - z}})}}{{1 - {e^{ - z}}}} + \frac{{\ln (i - i{e^z})}}{{1 - {e^z}}}} \right]dz} \\ & = \frac{\pi }{2}i\int_r^\infty {\frac{1}{{{x^2} + {\pi ^2}}}\frac{{{e^x} + 1}}{{{e^x} - 1}}dx} + \underbrace{\int_r^\infty {\frac{1}{{{x^2} + {\pi ^2}}}\left[ { - \frac{x}{{1 - {e^{ - x}}}} + \ln ({e^x} - 1)} \right]dx}}_J \end{aligned}$$ Along the semicircular indention, we have
$$\begin{aligned} - \int_{ - \pi }^0 {\frac{{\ln (i - i\exp ( - r{e^{iz}}))}}{{1 - \exp ( - r{e^{iz}})}}ri{e^{iz}}\frac{1}{{{r^2}{e^{2iz}} + {\pi ^2}}}} &= - \int_{ - \pi }^0 {\frac{{\ln (ir{e^{iz}})}}{{r{e^{iz}}}}ri{e^{iz}}\frac{1}{{{r^2}{e^{2iz}} + {\pi ^2}}}} + o(1) \\ &= - i\int_{ - \pi }^0 {\frac{{\ln r + x - \frac{\pi }{2}}}{{{r^2}{e^{2ix}} + {\pi ^2}}}dx} + o(1) \\ &= - \frac{i}{\pi }\ln r + o(1) \end{aligned}$$ Therefore $$\begin{aligned} PV\int_{ - \infty }^\infty {\frac{{\ln (i - i{e^{ - x}})}}{{1 - {e^{ - x}}}}\frac{1}{{{x^2} + {\pi ^2}}}dx} &= J + \frac{\pi }{2}i\int_r^\infty {\frac{1}{{{x^2} + {\pi ^2}}}\left[ {\frac{{{e^x} + 1}}{{{e^x} - 1}}} \right]dx} - \frac{i}{\pi }\ln r + o(1) \\& = J + \frac{\pi }{2}i\left[ {\int_r^\infty {\frac{1}{{{x^2} + {\pi ^2}}}\left( {\frac{{{e^x} + 1}}{{{e^x} - 1}} - \frac{2}{x}} \right)dx} + \int_r^\infty {\frac{2}{{x({x^2} + {\pi ^2})}}dx} - \frac{2}{{{\pi ^2}}}\ln r} \right] + o(1) \\& = J + \frac{\pi }{2}i\underbrace{\int_0^\infty {\frac{1}{{{x^2} + {\pi ^2}}}\left( {\frac{{{e^x} + 1}}{{{e^x} - 1}} - \frac{2}{x}} \right)dx}}_K + \frac{{i\ln \pi }}{\pi } + o(1) \end{aligned}$$ Plug this into $(2)$ and $(1)$:

$$\tag{3} - 8\Im I + 2\pi \left( K + \frac{{\ln \pi }}{\pi } \right) = \frac{{{\pi ^2}}}{2} $$ and $$\tag{4} - 8\Re I + 2\pi J = \pi \ln 2 - \pi $$

the evaluation of $\Re I$ is done in here, it has a nice closed form.


3. Conversion into series

Now we convert $K$ into a series: $$\begin{aligned} K &= \frac{1}{2} + 2\int_0^\infty {\frac{1}{{{x^2} + {\pi ^2}}}\left( {\frac{1}{{{e^x} - 1}} - \frac{1}{x}} \right)dx} \\ &= \frac{1}{2} + \frac{2}{\pi }\int_0^\infty {\int_0^\infty {\cos tx{e^{ - \pi t}}\left( {\frac{1}{{{e^x} - 1}} - \frac{1}{x}} \right)dt} dx} \\ &= \frac{1}{2} + \frac{2}{\pi }\int_0^\infty {{e^{ - \pi t}}\int_0^\infty {\left( {\frac{{\cos tx}}{{{e^x} - 1}} - \frac{{\cos tx}}{x}} \right)} dxdt} \\ &= \frac{1}{2} + \frac{2}{\pi }\int_0^\infty {{e^{ - \pi t}}\left( {\ln t + \gamma - \sum\limits_{n = 1}^\infty {\left( {\frac{1}{n} - \frac{n}{{{n^2} + {t^2}}}} \right)} } \right)dt} \\ &= \frac{1}{2} - \frac{{2\ln \pi }}{{{\pi ^2}}} - \frac{2}{\pi }\sum\limits_{n = 1}^\infty {\left( {\frac{1}{{n\pi }} + {{( - 1)}^n}\text{si}(n\pi )} \right)} \end{aligned}$$ Plug this into $(3)$ gives $$\Im I = - \frac{\pi }{4}\sum\limits_{n = 1}^\infty {\left( {\frac{1}{{n\pi }} + {{( - 1)}^n}\text{si}(n\pi )} \right)} $$

We start in another direction, use Fourier expansion on $\ln(\cos x)$, again denote $r$ be a small positive number: $$\begin{aligned} \int_r^{\pi /2} {\frac{{\ln (\cos x)}}{{{x^2}}}dx} &= \int_r^{\pi /2} {\frac{{ - \ln 2 - \sum\limits_{k = 1}^\infty {\frac{{{{( - 1)}^k}\cos 2kx}}{k}} }}{{{x^2}}}dx} \\&= - \ln 2\int_r^{\pi /2} {\frac{1}{{{x^2}}}dx} - \sum\limits_{k = 1}^\infty {\frac{{{{( - 1)}^k}}}{k}\int_r^{\pi /2} {\frac{{\cos 2kx}}{{{x^2}}}dx} } \\&= \frac{{2\ln 2}}{\pi } - \frac{{\ln 2}}{r} - \sum\limits_{k = 1}^\infty {\left( {\frac{{ - 2}}{{k\pi }} + \frac{{{{( - 1)}^k}\cos (2kr)}}{{kr}} - 2{{( - 1)}^k}\text{si}(k\pi ) + 2{{( - 1)}^k}\text{si}(2kr)} \right)} \\&= \frac{{2\ln 2}}{\pi } - \frac{{\ln 2}}{r} + 2\sum\limits_{k = 1}^\infty {\left( {\frac{1}{{k\pi }} + {{( - 1)}^k}\text{si}(k\pi )} \right)} - \sum\limits_{k = 1}^\infty {\left( {\frac{{{{( - 1)}^k}\cos (2kr)}}{{kr}} + 2{{( - 1)}^k}\text{si}(2kr)} \right)} \\&= \frac{{2\ln 2}}{\pi } + 2\left( { - \frac{4}{\pi }\Im I} \right) + \frac{{\ln (\cos r)}}{r} - 2\sum\limits_{k = 1}^\infty {{{( - 1)}^k}\text{si}(2kr)} \end{aligned}$$ Hence $(*)$ will be established if we can show

$$\tag{5} \sum_{n = 1}^\infty {{{( - 1)}^n}\text{si}(nr)} \to \frac{\pi }{4} \qquad \text{as } r\to 0^+$$

From the asymptotics of $\text{si}(x)$, the series converges conditionally for $0<r<\pi $, but diverges at $r=0$.


4. The final limit

To show $(5)$, fix an $0<a<1$, denote $$G(a,x) = \sum_{n = 1}^\infty ( - 1)^n{a^n}\text{si}(nx) $$ We can differentiate termwise for power series: $$\frac{{\partial G}}{{\partial x}} = \sum\limits_{n = 1}^\infty {{{( - 1)}^n}n{a^n}\frac{{\sin nx}}{{nx}}} = \frac{1}{x}\sum\limits_{n = 1}^\infty {{{( - 1)}^n}{a^n}\sin nx} = \frac{1}{x}\frac{{ - a\sin x}}{{{a^2} + 2a\cos x + 1}}$$ Hence $$\tag{6} G(a,x) = C_a + \int_0^x {\frac{{ - a\sin t}}{{t({a^2} + 2a\cos t + 1)}}dt} $$ where $C_a$ is a constant depending on $a$. For a fixed $0<a<1$, $G(a,x) \to 0$ as $x\to \infty$, thus $$0 = C_a + \int_0^\infty {\frac{{ - a\sin t}}{{t({a^2} + 2a\cos t + 1)}}dt} $$ The improper integral is easily to evaluate: $$\int_0^\infty {\frac{{ - a\sin t}}{{t({a^2} + 2a\cos t + 1)}}dt} = \sum\limits_{k = 1}^\infty {{{( - 1)}^n}{a^n}\int_0^\infty {\frac{{\sin kt}}{t}dt} } = -\frac{\pi a}{{2(1 + a)}}$$ yielding $C_a = \frac{\pi a}{2(1+a)}$. Now by Abel's theorem, take limit $a\to 1^-$ in $(6)$: $$G(1^-,x) = \sum_{n = 1}^\infty ( - 1)^n\text{si}(nx) = \frac{\pi }{4} + \int_0^x {\frac{{ - \sin t}}{{t(2 + 2\cos t)}}dt} $$ this proves $(5)$, and with it, the relation claimed by OP.


Numeric confirmation

From Mathematica. Left hand side: lhs

Right hand side: rhs

$$ f(z) = \frac{\ln \cos x}{x^2} $$ re im

$$ \text{Im }f(z) = \frac{z^2}{z^2+\ln^{2} \left(-2 \cos z \right)} $$

im