# An astounding identity: $\int_0^{\pi/2}\ln\lvert\sin(mx)\rvert\cdot \ln\lvert\sin(nx)\rvert\, dx$

In this question, user Franklin Pezzuti Dyer gives the following surprising integral evaluation:

$$\int_0^{\pi/2}\ln \lvert\sin(mx)\rvert \cdot \ln \lvert\sin(nx)\rvert \, dx = \frac{\pi^3}{24} \frac{\gcd^2(m,n)}{mn}+\frac{\pi\ln^2(2)}{2}$$

I've verified this numerically for small values for $$m,n$$. Is there a proof? Also, can we generalize it to more factors in the integrand?

• I don't have a proof, but I would find it even more aesthetical with $\frac{\gcd(m,n)}{\operatorname{lcm}(m,n)}$ instead of $\frac{\gcd^2(m,n)}{mn}$. Commented Jun 20, 2018 at 21:08
• This will probably require a lot more thinking, but have you tried replacing the absolute value signs with $\sqrt{(\cdot)^2}$? Commented Jun 20, 2018 at 21:09
• @ArnaudMortier You can edit if you like, but I think I prefer the original. Commented Jun 20, 2018 at 21:20
• @FrankW That could be a good first step, sure. Commented Jun 20, 2018 at 21:20

Okay, I'll prove it for you.

Start with the following well-known identity: $$\int_0^{\pi}\cos(mx)\cos(nx)dx=\frac{\pi}{2}\delta_{mn}\tag{1}$$ ...where $$m,n$$ are positive integers. Recall also the well-known Fourier Series $$\sum_{n=1}^\infty \frac{\cos(kx)}{k}=-\frac{\ln(2-2\cos(x))}{2}\tag{2}$$ Now, replace $$m$$ in $$(1)$$ with $$mk$$, where both $$m,k$$ are integers, and divide both sides by $$k$$ to get $$\int_0^{\pi}\frac{\cos(kmx)}{k}\cos(nx)dx=\frac{\pi\delta_{(mk)n}}{2k}$$ Then sum both sides from $$k=1$$ to $$\infty$$ to get $$-\frac{1}{2}\int_0^{\pi}\ln(2-2\cos(mx))\cos(nx)dx=\frac{\pi m}{2n}[m|n]$$ where the brackets on the $$RHS$$ are Iverson Brackets. A bit more manipulation yields the equality $$\int_0^{\pi}\ln\bigg(\frac{1-\cos(mx)}{2}\bigg)\cos(nx)dx=-\frac{\pi m}{n}[m|n]$$ Now, this time, replace $$n$$ with $$nk$$ and divide both sides by $$k$$. This yields $$\int_0^{\pi}\ln\bigg(\frac{1-\cos(mx)}{2}\bigg)\frac{\cos(knx)}{k}dx=-\frac{\pi m}{k^2n}[m|kn]$$ Then sum from $$k=1$$ to $$\infty$$ to get $$-\frac{1}{2}\int_0^{\pi}\ln\bigg(\frac{1-\cos(mx)}{2}\bigg)\ln(2-2\cos(nx))dx=-\sum_{k=1}^{\infty} \frac{\pi m}{k^2n}[m|kn]$$ Now notice the following about the series on the RHS. Due to the Iverson Bracket, the kth term is zero unless $$m|kn$$, or unless $$k$$ is divisible by $$m/\gcd(m,n)$$. Thus, we let $$k=jm/\gcd(m,n)$$ for the integers $$j=1$$ to $$\infty$$ and reindex the sum: \begin{align} -\frac{1}{2}\int_0^{\pi}\ln\bigg(\frac{1-\cos(mx)}{2}\bigg)\ln(2-2\cos(nx))dx &=-\sum_{j=1}^{\infty} \frac{\pi m}{(jm/\gcd(m,n))^2n}\\ &=-\frac{\pi\gcd^2(m,n)}{mn}\sum_{j=1}^{\infty} \frac{1}{j^2}\\ &=-\frac{\pi^3\gcd^2(m,n)}{6mn}\\ \end{align} or $$\int_0^{\pi}\ln\bigg(\frac{1-\cos(mx)}{2}\bigg)\ln(2-2\cos(nx))dx=\frac{\pi^3\gcd^2(m,n)}{3mn}\tag{3}$$ Then, by using the result $$\int_0^{\pi}\ln(1-\cos(ax))=-\pi\ln(2)\tag{4}$$ for all positive integers $$a$$, and the trigonometric identity $$\sin^2(x/2)=\frac{1-\cos(x)}{2}\tag{5}$$ and finally, a substitution $$x\to 2x$$, the result easily follows from $$(3)$$ : $$\bbox[lightgray,5px]{\int_0^{\pi/2}\ln \lvert\sin(mx)\rvert \cdot \ln \lvert\sin(nx)\rvert \, dx = \frac{\pi^3}{24} \frac{\gcd^2(m,n)}{mn}+\frac{\pi\ln^2(2)}{2}}$$

• Very, very nice! I'll accept this later once I have a chance to go through it properly. Commented Jun 20, 2018 at 22:00
• This looks good - a beautiful proof of a beautiful fact. Although, I believe you are missing a few factors of $\pi/2$. I'll accept your answer after a couple days to see if others can provide alternate proofs. Commented Jun 21, 2018 at 3:19
• What does the $\delta$ function mean at the end of equation $(1)$?$$\int\limits_0^{\pi}dx\,\cos mx\cos nx=\frac {\pi}2\color{blue}{\delta_{mn}}$$ Commented Jun 21, 2018 at 21:27
• @FrankW.,This is the Kronecker delta, equal to $1$ if $m=n$ and $0$ otherwise. Commented Jun 21, 2018 at 21:37
• This isn't quite relevant to the question, but using the same technique in the linked question, I get$$\int\limits_0^{1}dt\,\frac {t^a(1-t)^b}{z-t^s(1-t)^k}=\sum\limits_{n\geq0}\frac {\Gamma(sn+a+1)\Gamma(kn+b+1)}{z^{n+1}\Gamma(a+b+n(s+k)+2)}$$which comes from the beta function and taking the sum from $n=0$ to $\infty$. It looks kinda promising to me... Commented Jun 22, 2018 at 15:45

Though, I think the Fourier series approach is the cleaner approach for this integral, I'd like to present a somewhat unique alternative method. This integral may be evaluated by exploiting symmetry and the following multiple-angle identity: $$$$\sin(mx)=2^{m-1}\prod_{k=0}^{m-1}\sin\left(x+\frac{\pi k}{m}\right)$$$$ Your integral is equal to $$\frac{1}{2}I(m,n)$$ where $$$$I(m,n)=\int_0^{\pi}\ln|\sin(mx)|\cdot\ln|\sin(nx)|dx$$$$

First, suppose than $$m,n$$ are coprime. We see that $$$$\begin{split} I(1,n)&=\int_0^{\pi}\ln|\sin(x)|\cdot\ln|\sin(nx)|dx\\ &=\int_0^{\pi}\ln|\sin(mx)|\cdot\ln|\sin(mnx)|dx\\ \end{split}$$$$ since the integrand has period $$\pi$$. Applying the multiple-angle formula for $$\sin$$ gives us that $$$$I(1,n)=\sum_{k=0}^{m-1}\int_0^{\pi}\ln|\sin(mx)|\cdot\ln|\sin(nx+\pi k/m)|dx+ (m-1)\ln(2)\int_0^{\pi}\ln|\sin(mx)|dx$$$$ Since $$n,m$$ are coprime, then the map $$k\mapsto nk$$ is an automorphism on $$\mathbb{Z}/m$$, meaning that $$$$\begin{split} I(1,n)&=\sum_{k=0}^{m-1}\int_0^{\pi}\ln|\sin(mx)|\cdot\ln|\sin(nx+\pi nk/m)|dx \\ &\qquad\qquad + (m-1)\ln(2)\int_0^{\pi}\ln|\sin(mx)|dx\\ &=\sum_{k=0}^{m-1}\int_0^{\pi}\ln|\sin(m[x+\pi k/m])|\cdot\ln|\sin(n[x+\pi k/m])|dx \\ &\qquad\qquad+(m-1)\ln(2)\int_0^{\pi}\ln|\sin(mx)|dx\\ \end{split}$$$$ Again, since the integrands have period $$\pi$$ we may simplify $$$$\begin{split} I(1,n)&=\sum_{k=0}^{m-1}\int_0^{\pi}\ln|\sin(mx)|\cdot\ln|\sin(nx)|dx+(m-1)\ln(2)\int_0^{\pi}\ln|\sin(x)|dx\\ &=mI(m,n)+(m-1)\ln(2)J\\ \end{split}$$$$ where $$$$J=\int_0^{\pi}\ln(\sin(x))dx$$$$ Noting that $$I(1,n)=I(n,1)$$ and applying the above identity twice gives us that $$$$I(m,n)=\frac{1}{mn}[I(1,1)+\ln(2)J]-\ln(2)J$$$$

Now, in the case where $$m,n$$ are not coprime, then $$\frac{m}{\gcd(m,n)},\frac{n}{\gcd(m,n)}$$ are coprime, so by the periodicity of the integrand, $$$$I(m,n)=I\left(\frac{m}{\gcd(m,n)},\frac{n}{\gcd(m,n)}\right)=\frac{\gcd^2(m,n)}{mn}[I(1,1)+\ln(2)J]-\ln(2)J$$$$

Finally, $$I(1,1)$$ and $$J$$ are somewhat famous integrals which may be evaluated in a few different ways. This answer shows that $$$$J=-\pi\ln(2)$$$$ using an elementary method, and in this answer I use a complex-analytic method to show that $$$$I(1,1)=\pi\ln^2(2)+\frac{\pi^3}{12}$$$$ Putting these facts together, we have that $$$$I(m,n)=\frac{\pi^3}{12}\frac{\gcd^2(m,n)}{mn}+\pi\ln^2(2)$$$$ In other words, the original integral is given by $$$$\boxed{\int_0^{\pi/2}\ln|\sin(mx)|\cdot\ln|\sin(nx)|dx= \frac{\pi^3}{24}\frac{\gcd^2(m,n)}{mn}+\frac{\pi\ln^2(2)}{2}}$$$$ which I think is a really beautiful result.

A generalization of this integral is $$\small \int_{0}^{\pi} \ln \left(1-2 e^{- \phi} \cos (mx) + e^{- 2\phi} \right) \ln \left( 1-2 e^{- \lambda} \cos(nx) +e^{-2 \lambda}\right) \, \mathrm dx= \frac{2\pi \gcd^{2} (m,n) \operatorname{Li}_{2} \left(\exp \left(- \, \frac{m\lambda +n \phi}{\gcd(m,n)} \right) \right)}{mn} ,$$ where $$\operatorname{Li}_{2}(-)$$ is the dillogarithm, $$m$$ and $$n$$ are positive integers, and $$\phi, \lambda \ge 0$$.

To prove this result, we'll use the Fourier series $$\sum_{n=1}^{\infty} \frac{e^{- k \phi} \cos(k \theta)}{k} = - \frac{1}{2} \, \ln \left(1-2 e^{- \phi} \cos(\theta) +e^{- 2 \phi} \right),$$ which can be derived by extracting the real part of the identity $$\sum_{k=1}^{\infty} \frac{\left(e^{-\phi}e^{i \theta}\right)^{k}}{k} = - \ln \left(1-e^{- \phi} e^{i \theta} \right).$$

We get

\begin{align} &\int_{0}^{\pi} \ln \left(1-2 e^{- \phi} \cos (mx) + e^{- 2\phi} \right) \ln \left( 1-2 e^{- \lambda} \cos(nx) +e^{-2 \lambda}\right) \, \mathrm dx \\&= 4 \int_{0}^{\pi} \sum_{j=1}^{\infty}\frac{e^{- j \phi}\cos(jm x)}{j} \sum_{k=1}^{\infty} \frac{e^{-k \lambda }\cos(kn x)}{k} \mathrm d x \\ &= 4 \sum_{j=1}^{\infty} \sum_{k=1}^{\infty} \frac{e^{- j \phi} e^{- k \lambda}}{jk} \int_{0}^{\pi} \cos(j m x) \cos(kn x) \, \mathrm d x \\ &= 2 \pi \sum_{j=1}^{\infty} \sum_{k=1}^{\infty} \frac{e^{- j \phi} e^{- k \lambda}}{jk} \, \delta_{jm, kn} \\ &= 2 \pi \sum_{p=1}^{\infty} \frac{mn }{p \operatorname{lcm}(m,n) p \operatorname{lcm}(m,n)} \, \exp \left(-\frac{p \operatorname{lcm}(m,n)}{m} \phi - \frac{p\operatorname{lcm}(m,n)}{n} \lambda \right) \\ &= \frac{2 \pi \gcd^{2}(m,n)}{mn} \, \sum_{p=1}^{\infty} \frac{1}{p^{2}} \, \exp \left(- p \, \frac{m\lambda +n \phi }{\gcd(m,n)} \right) \\ &= \frac{2 \pi \gcd^{2}(m,n)}{mn} \, \operatorname{Li}_{2} \left(\exp \left(- \, \frac{m \lambda+n \phi}{\gcd(m,n)} \right) \right). \end{align}

When the value of the integral is very small, Wolfram Alpha sometimes incorrectly says that the value of the integral is zero.

For $$\phi=0$$ and $$\lambda =0$$, we have \begin{align} &\int_{0}^{\pi} \ln \left(2-2 \cos(mx) \right) \ln \left(2-2 \cos(nx)\right) \, \mathrm dx \\ &= \int_{0}^{\pi} \ln \left(4 \ \frac{1-\cos(mx)}{2} \right) \ln \left(4 \ \frac{1+ \cos(nx)}{2} \right) \, \mathrm dx \\ &= \small \pi \ln^{2}(4) + \ln(4) \left( \int_{0}^{\pi} \ln\left(\frac{1- \cos(mx)}{2} \right) \, \mathrm dx + \int_{0}^{\pi} \ln \left(\frac{1- \cos(nx)}{2} \right) \, \mathrm dx \right) \\ &+ \small \int_{0}^{\pi} \ln \left(\frac{1- \cos(mx)}{2} \right) \ln \left(\frac{1-\cos(nx)}{2} \right) \, \mathrm dx \\ &\overset{(1)}{=} \small \pi \ln^{2}(4) + \ln(4) \left(-2 \pi \ln(2) -2 \pi \ln(2) \right)+ 2 \int_{0}^{\pi/2} \ln \left(\frac{1- \cos(2mt)}{2} \right) \ln \left(\frac{1-\cos(2nt)}{2} \right) \, \mathrm dt \\&= \color{red}{-4 \pi \ln^{2}(2) +8 \int_{0}^{\pi/2} \ln |\sin(mt)| \ln |\sin(nt) | \, \mathrm dt} \\ & = \frac{2 \pi \gcd^{2}(m,n)}{mn} \, \operatorname{Li}_{2} (1) \\ &= \frac{2 \pi \gcd^{2}(m,n)}{mn} \, \zeta(2) \\ &= \frac{\pi^{3}}{3} \frac{\gcd^{2}(m,n)}{mn}. \end{align}

$$(1)$$

For an positive integer $$m$$, \begin{align} \int_{0}^{\pi} \ln \left(\frac{1-\cos(mx)}{2} \right) \, \mathrm dx &= \frac{1}{m} \int_{0}^{m \pi} \ln \left(\frac{1-\cos(u)}{2} \right) \, \mathrm du \\ &= \frac{1}{m} \sum_{k=0}^{m-1} \int_{k \pi}^{(k+1) \pi} \ln \left(\frac{1-\cos(u)}{2} \right) \, \mathrm du \\ &= \frac{1}{m} \sum_{k=0}^{m-1} \int_{0}^{\pi} \ln \left(\frac{1 -(-1)^{k} \cos(v)}{2} \right) \, \mathrm dv \\ &= \frac{1}{m} \sum_{k=0}^{m-1} \int_{0}^{\pi} \ln \left(\frac{1 - \cos(v)}{2} \right) \, \mathrm dv \\ &= \int_{0}^{\pi} \ln \left(\frac{1 - \cos(v)}{2} \right) \, \mathrm dv \\ &= \int_{0}^{\pi } \ln \left(\sin^{2}\left(\frac{u}{2}\right) \right) \, \mathrm dv \\ &= 4 \int_{0}^{\pi/2} \ln \left(\sin (v) \right) \, \mathrm dv \\ &= -2 \pi \ln(2) . \end{align}

I was going to use $$|r| \le 1$$ and $$|s| \le 1$$ instead of $$e^{- \theta}$$ and $$e^{- \lambda}$$, but I chose the later because it looked cleaner.

• Nice generalization. It's nice to see this question getting additional attention. Commented Oct 2, 2023 at 1:29