# Calculate $\int_0^1\frac{(\ln x)^2}{\sqrt{x-x^2}}dx=?$

Find the:

$$\int_0^1\frac{(\ln x)^2}{\sqrt{x-x^2}}\,dx=\text{?}$$

My Try :

$$u=\sqrt{x-x^2} \\ du=\frac{-2x+1}{2\sqrt{x-x^2}}\,dx\\dx=\frac{2\sqrt{x-x^2}}{-2x+1}\,du$$

So we have :

$$\int_0^1\frac{(\ln x)^2}{\sqrt{x-x^2}}\,dx=\int_0^1\frac{2(\ln x)^2}{(-2x+1)}\,du$$

Now what ?

• The answer does not looks simple – Bumblebee Nov 14 '17 at 16:47
• You can't integrate a function of x with respect to u! Can you convert $\frac{2(ln(x))^2}{1- 2x}$ to a function of u? – user247327 Nov 14 '17 at 16:50
• Are you sure it is correct the integral? The result can be found using special functions $$\int \frac{\log ^2(x)}{\sqrt{x-x^2}} \, dx=2 \left(8 \sqrt{x} \, _4F_3\left(\frac{1}{2},\frac{1}{2},\frac{1}{2},\frac{1}{2};\frac{3}{2},\frac{3}{2},\frac{3}{2};x\right)+\\ \log x \left(\log x \arcsin\sqrt{x}-4 \sqrt{x} \, _3F_2\left(\frac{1}{2},\frac{1}{2},\frac{1}{2};\frac{3}{2},\frac{3}{2};x\right)\right)\right)$$ – Raffaele Nov 14 '17 at 16:55
• How did you manage the change of varaiables I think you forgot the log factor – Guy Fsone Nov 14 '17 at 17:04
• According to Wolfram, $\int_0^1 \frac{\log ^2(x)}{\sqrt{x-x^2}} \, dx=\frac{\pi^3}{3}+4\pi\ln^2 2$ – FDP Nov 14 '17 at 17:13

This is a simple integral. By Euler's Beta function $$\int_{0}^{1}\frac{x^\alpha}{\sqrt{x(1-x)}}\,dx = \frac{\Gamma\left(\alpha+\tfrac{1}{2}\right)}{\Gamma(\alpha+1)}\cdot \alpha\sqrt{\pi}\tag{1}$$ for any $\alpha>-\frac{1}{2}$, hence it is enough to apply $\frac{d^2}{d\alpha^2}$ to both sides of $(1)$, then evaluate at $\alpha=0$.
It is pratical to write $\frac{dg}{d\alpha}$ as $g\cdot\frac{d}{d\alpha}\log g$ and recall that $\psi=\frac{d}{d\alpha}\log\Gamma$ and $$\psi(1)=-\gamma,\quad \psi\left(\tfrac{1}{2}\right)=-\gamma-\log(4),\quad \psi'(1)=\frac{\pi^2}{6},\quad \psi'\left(\tfrac{1}{2}\right)=\frac{\pi^2}{2}$$ to get $$\int_{0}^{1}\frac{\log^2(x)}{\sqrt{x(1-x)}}\,dx = \color{red}{\frac{\pi^3}{3}+4\pi\log^2(2)}.\tag{2}$$ This can be proved by Fourier-Legendre series expansions, too. Indeed, the hypergeometric functions mentioned by Raffaele in the comments have simple closed forms at $x\in\left\{0,\frac{1}{2},1\right\}$. Have a look at page 39 here.

Yet another (brutally efficient) approach is to apply Parseval's theorem to the Fourier series of $\log\sin$, which can be derived from the identity $\sum_{n\geq 1}\frac{\cos(n\theta)}{n}=-\log\left|2\sin\frac{\theta}{2}\right|$. This also explains why the Euler-Mascheroni constant $\gamma$ disappears from the RHS of $(2)$.

Additionally, the similar integral $\int_{0}^{1}\frac{\log^3(x)}{\sqrt{1-x^2}}\,dx$ is computed at page 76 of my notes through the same technique used above (Feynman's trick and special values for $\Gamma,\psi,\psi',\psi''$). Here there are no simple ways for applying Parseval's theorem, hence the approach by differentiation under the integral sign is a bit more general, even if Fourier series solve OP's problem sooner.

• +1 because you are the best. Just a note: I think the OP has no knowledge of Gamma and/or Beta function, to say nothing of digamma or Euler constant. Thank you for enlighten this dark place... – Raffaele Nov 14 '17 at 17:34
• @Raffaele: you are too kind. Anyway, the linked notes may serve as a brief introduction to Feynman's trick and special functions, too. There are dedicated sections, if the OP or anyone else is interested. – Jack D'Aurizio Nov 14 '17 at 18:15

It turns out that this integral can be evaluated using complex analysis techniques. And, I am happy to report, this approach leads to a formulation that I have never seen before, and the analysis involves an unexpected use of residues.

OK, so to begin we define a complex integral with an integrand and a contour of integration as follows:

$$\oint_C dz \, \frac{\log^2{z}}{\sqrt{z (z-1)}}$$

where $C$ is the following contour:

with the large arc having radius $R$ and the small arcs having radius $\epsilon$. By Cauchy's theorem, the integral is zero. Then again, by parametrizing the various portions of $C$, the complex integral above is also equal to

$$e^{i \pi} \int_R^{\epsilon} dx \frac{\left ( \log{x}+i \pi \right )^2}{e^{i \pi} \sqrt{x (x+1)}} + i \epsilon \int_{\pi}^0 d\phi \, e^{i \phi} \frac{\left ( \log{\epsilon}+i \phi \right )^2}{\sqrt{\epsilon e^{i \phi} \left ( \epsilon e^{i \phi} - 1 \right )}} \\ + e^{-i \pi/2} \int_{\epsilon}^{1-\epsilon} dx \frac{\log^2{x}}{\sqrt{x (1-x)}} + i \epsilon \int_{\pi}^{-\pi} d\phi \, e^{i \phi} \frac{\left ( \log{\epsilon}+i \phi \right )^2}{\sqrt{ \left (1 + \epsilon e^{i \phi} \right ) \epsilon e^{i \phi}}} \\ + e^{i \pi/2} \int_{1-\epsilon}^{\epsilon} dx \frac{\log^2{x}}{\sqrt{x (1-x)}} + i \epsilon \int_0^{-\pi} d\phi \, e^{i \phi} \frac{\left ( \log{\epsilon}+i \phi \right )^2}{\sqrt{\epsilon e^{i \phi} \left ( \epsilon e^{i \phi} - 1 \right )}} \\ + e^{-i \pi} \int_{\epsilon}^R dx \frac{\left ( \log{x}-i \pi \right )^2}{e^{-i \pi} \sqrt{x (x+1)}}+ i R \int_{-\pi}^{\pi} d\theta \, e^{i \theta} \frac{\left ( \log{R} + i \theta \right )^2}{\sqrt{R e^{i \theta} \left ( R e^{i \theta} - 1 \right )}} = 0\tag{1}$$

In the limit as $\epsilon \to 0$, the second, fourth, and sixth integrals approach zero. We can then combine the first and seventh integrals, and the third and fifth integrals (and note the significant cancellations). We then have, after rewriting the eighth integral:

$$-i 4 \pi \int_0^R dx \, \frac{\log{x}}{\sqrt{x (1+x)}} - i 2 \int_0^1 dx \frac{\log^2{x}}{\sqrt{x (1-x)}} \\ + i \int_{-\pi}^{\pi} d\theta \, \left ( \log^2{R} + i 2 \theta \log{R} - \theta^2 \right ) \left ( 1 - \frac1{R e^{i \theta}} \right )^{-1/2} = 0\tag{2}$$

As $R \to \infty$, the last factor in the third integral approaches $1$, so we can ignore it. Accordingly, after rearranging the above equation, we have the following expression for the original integral:

$$\int_0^1 dx \frac{\log^2{x}}{\sqrt{x (1-x)}} = \lim_{R \to \infty} \left (-2 \pi \int_0^R dx \frac{\log{x}}{\sqrt{x (1+x)}} + \pi \log^2{R} - \frac{\pi^3}{3} \right )\tag{3}$$

(Begin soapbox)

In my opinion, the above represents an extraordinary expression for the original integral. Typically, a problem like this would have us express the original integral in terms of a "residue at infinity" and/or residues at finite poles. In this case, however, the logarithm has forced us to consider pieces of the contour that we have been able to throw away previously. Specifically, the pieces of the contour that connect the "dogbone" to the larger arc play a crucial role here, whereas without the logarithm we have been able to ignore those pieces.

This is where I believe the "residue at infinity" approach fails us. By leading us to think that the "dogbone" contour is the correct contour in its entirety, we would completely miss this aspect of the problem in which we must now go and figure out how to cancel the singularities in the limit as $R \to \infty$.

(End soapbox)

OK, so we now have the problem of finding the asymptotic behavior of the first integral is the equation above as $R \to \infty$. We begin by slightly rearranging the integral:

$$\int_0^R dx \frac{\log{x}}{\sqrt{x (1+x)}} = 2 \sqrt{R} \log{R} \int_0^1 \frac{dt}{\sqrt{1+R t^2}} + 4 \sqrt{R} \int_0^1 dt \frac{\log{t}}{\sqrt{1+R t^2}} \tag{4}$$

While we can evaluate the first integral easily, the second integral is not amenable to a simple analytical evaluation. Further, the usual approach to asymptotic analysis using asymptotic matching leads to an unwieldy analysis that would render this method useless - much more complicated than a real approach to evaluating the original integral.

Fortunately, there is a well-known approach to determining asymptotic behavior of integrals with general, smooth and integrable kernels. I will summarize the theory below, which one may find in great detail in N. Bleistein and R. Handelsman, "Asymptotic Expansions of Integrals," Secs. 4.1-4.4.

Consider the integral

$$I(\lambda) = \int_0^{\infty} dt \, f(t) h(\lambda t)$$

where $\lambda \gt 0$ and $f$ and $h$ satisfy certain convergence properties in respective vertical strips in the complex plane. Then the following Parseval relation is true:

$$I(\lambda) = \frac1{i 2 \pi} \int_{c-i \infty}^{c+i \infty} ds \, \lambda^{-s} F(1-s) H(s) \tag{5}$$

where $\operatorname{Re}{s}=c$ is in a vertical strip common to both $f$ and $h$ and $F$ and $H$ are, respectively, the Mellin transforms of $f$ and $h$:

$$F(s) = \int_0^{\infty} dt \, f(t) \, t^{s-1} \tag{6a}$$ $$H(s) = \int_0^{\infty} dt \, h(t) \, t^{s-1} \tag{6b}$$

By using analytical continuation, the line of integration may be moved out to the right to a line $\operatorname{Re}{s}=L$, where $L \gt c$. We can complete a rectangular contour, with the horizontal pieces vanishing as $L \to \infty$. The integral may then be written, by the residue theorem, as

$$I(\lambda) = -\sum_{j \ni c \lt \operatorname{Re}{s_j} \lt L} \operatorname*{Res}_{s=s_j}\left [ \lambda^{-s} F(1-s) H(s) \right ] + \frac1{i 2 \pi} \int_{L-i \infty}^{L+i \infty} ds \, \lambda^{-s} F(1-s) H(s) \tag{7}$$

(Note that the residue contribution is negative because the contour of integration is oriented clockwise.) For $L$ large enough, the integral on the RHS is negiglible compared to the residues in the sum. We thus have the following asymptotic relation:

$$\int_0^{\infty} dt \, f(t) h(\lambda t) = -\sum_{j \ni c \lt \operatorname{Re}{s_j} \lt L} \operatorname*{Res}_{s=s_j}\left [ \lambda^{-s} F(1-s) H(s) \right ] + O \left ( \lambda^{-L} \right )\tag{8}$$

(For a proof, see the above reference.) And here, at last, we see a surprising appearance of residues!

We will use the above asymptotic relation for the integrals defining our limits as $R \to \infty$. In our case, $\lambda = \sqrt{R}$, $h(t) = \left ( 1+t^2 \right )^{-1/2}$, and $f_{1,2}(t)$ equals either $\theta(t) \theta(1-t)$ (1) or $\theta(t) \theta(1-t) \log{t}$ (2), where $\theta$ refers to the Heaviside step function here. Accordingly,

$$H(s) = \frac1{2 \sqrt{\pi}} \Gamma \left (\frac{s}{2} \right ) \Gamma \left (\frac{1-s}{2} \right ) \tag{9a}$$

$$F_1(1-s) = \frac1{1-s} \tag{9b}$$ $$F_2(1-s) = -\frac1{(1-s)^2} \tag{9c}$$

Now, note that we need only consider, for the leading asymptotic behavior of these integrals, the pole at $s=1$. (Poles at $s=3$ and beyond will have subdominant behavior.) Thus, we need only consider

$$\operatorname*{Res}_{s=1}\left [ R^{-s/2} \frac{\Gamma \left (\frac{s}{2} \right ) \Gamma \left (\frac{1-s}{2} \right )}{2 \sqrt{\pi} (1-s)} \right ] = \frac{\log{R}}{2 \sqrt{R}} + \frac{\log{2}}{\sqrt{R}}\tag{10a}$$

$$\operatorname*{Res}_{s=1}\left [ -R^{-s/2} \frac{\Gamma \left (\frac{s}{2} \right ) \Gamma \left (\frac{1-s}{2} \right )}{2 \sqrt{\pi} (1-s)^2} \right ] = -\frac{\log^2{R}}{8 \sqrt{R}} - \frac{\log{2} \log{R}}{2 \sqrt{R}} - \frac{\pi^2 + 6 \log^2{2}}{12 \sqrt{R}}\tag{10b}$$

The above residues were evaluated by noting that the pole at $s=1$ is a double pole in the former integrand and a triple pole in the latter integrand. Now we may take these results and plug them into the limit expression for the original integral:

\begin{align} \int_0^1 dx \frac{\log^2{x}}{\sqrt{x (1-x)}} &= \lim_{R \to \infty} \left (-2 \pi \int_0^R dx \frac{\log{x}}{\sqrt{x (1+x)}} + \pi \log^2{R} - \frac{\pi^3}{3} \right ) \\ &= \lim_{R \to \infty} \left (-2 \pi \left [ 2 \sqrt{R} \log{R} \int_0^1 \frac{dt}{\sqrt{1+R t^2}} + 4 \sqrt{R} \int_0^1 dt \frac{\log{t}}{\sqrt{1+R t^2}} \right ] + \pi \log^2{R} - \frac{\pi^3}{3} \right ) \\ &= \lim_{R \to \infty} \left (-2 \pi \left [ 2 \sqrt{R} \log{R} \left ( \frac{\log{R}}{2 \sqrt{R}} + \frac{\log{2}}{\sqrt{R}} \right ) + 4 \sqrt{R} \left (-\frac{\log^2{R}}{8 \sqrt{R}} - \frac{\log{2} \log{R}}{2 \sqrt{R}} - \frac{\pi^2 + 6 \log^2{2}}{12 \sqrt{R}} \right ) \right ] + \pi \log^2{R} - \frac{\pi^3}{3} \right ) \\ &= \lim_{R \to \infty} \left (-2 \pi \log^2{R} - 4 \pi \log{2} \log{R} + \pi \log^2{R} + 4 \pi \log{2} \log{R} + \frac{2 \pi^3 + 12 \pi \log^2{2}}{3} + \pi \log^2{R} - \frac{\pi^3}{3} \right ) \end{align}

Note that all terms depending on $R$ cancel, and we finally have

$$\int_0^1 dx \frac{\log^2{x}}{\sqrt{x (1-x)}} = \frac{\pi^3}{3} + 4 \pi \log^2{2} \tag{11}$$

I know this was a long read, but I hope by introducing the Mellin transform approach to determining the limit we needed, the approach ended up expressing the original integral in terms of other integrals that could be evaluated - or in this case, approximated, more simply. I think it led to completely new places to which I have never been, and I hope this leads the way to more interesting integral evaluations using complex analysis.

• Hello there! I've noticed that you got a cool blog where you post integrals alongside with solution and I really like that idea. Would it be possible to tell me how to start building such a website from scratch? Or some relevant links that explains how, would also help me alot. – カカロット Aug 12 at 21:50
• Hi, I use Wordpress, but I store my data on a remote server. The website is mostly stuff I have posted here with a few embellishments, no big deal. Wordpress has some nice tools like Mathjax etc. just go to wordpress.org (or com) and follow the instructions. You can make a post by copying and pasting a post you made here into the editor there and adjusting to get the page to look the way you want it. – Ron Gordon Aug 12 at 22:01
• Thank you, I will give it a try! – カカロット Aug 12 at 22:07

$\displaystyle J=\int_0^1 \frac{\ln^2 x}{\sqrt{x(1-x)}}\,dx$

Perform the change of variable $x=\sin^2 \theta$,

$\displaystyle J=8\int_0^{\frac{\pi}{2}}\ln^2(\sin \theta)\,d\theta$

Observe that,

$\displaystyle K=\int_0^{\frac{\pi}{2}}\ln^2(\sin \theta)\,d\theta=\int_0^{\frac{\pi}{2}}\ln^2(\cos \theta)\,d\theta$

(perform the change of variable $\displaystyle y=\frac{\pi}{2}-x$ )

\begin{align} K&=\int_0^{\frac{\pi}{2}}\ln^2(\tan \theta\cos \theta)\,d\theta\\ &=\int_0^{\frac{\pi}{2}} \left(\ln\left(\tan \theta\right)+\ln\left(\cos\theta\right) \right)^2\,d\theta\\ &=\int_0^{\frac{\pi}{2}}\ln^2\left(\tan \theta\right)\,d\theta+K+2\int_0^{\frac{\pi}{2}} \ln\left(\tan \theta\right)\ln\left(\cos \theta\right)\,d\theta\\ &=\int_0^{\frac{\pi}{2}}\ln^2\left(\tan \theta\right)\,d\theta+K+2\int_0^{\frac{\pi}{2}}\Big(\ln(\sin \theta)-\ln(\cos \theta)\big)\ln(\cos \theta)\,d\theta\\ &=\int_0^{\frac{\pi}{2}}\ln^2\left(\tan \theta\right)\,d\theta-K+2\int_0^{\frac{\pi}{2}}\ln(\sin \theta)\ln(\cos \theta)\,d\theta \end{align}

Therefore,

$\displaystyle 2K=\int_0^{\frac{\pi}{2}}\ln^2\left(\tan \theta\right)\,d\theta+2\int_0^{\frac{\pi}{2}}\ln(\sin \theta)\ln(\cos \theta)\,d\theta$

but,

\begin{align}4\int_0^{\frac{\pi}{2}}\ln(\sin \theta)\ln(\cos \theta)\,d\theta&=\int_0^{\frac{\pi}{2}} \Big(\big(\ln(\sin \theta)+\ln(\cos \theta)\big)^2-\big(\ln(\sin \theta)-\ln(\cos \theta)\big)^2\Big)\,d\theta\\ &=\int_0^{\frac{\pi}{2}}\ln^2(\sin \theta\cos \theta)\,d\theta-\int_0^{\frac{\pi}{2}}\ln^2(\tan \theta)\,d\theta\end{align}

Therefore,

$\displaystyle 2K=\frac{1}{2}\int_0^{\frac{\pi}{2}}\ln^2\left(\tan \theta\right)\,d\theta+\frac{1}{2}\int_0^{\frac{\pi}{2}}\ln^2(\sin \theta\cos \theta)\,d\theta$

But,

$\displaystyle L=\int_0^{\frac{\pi}{2}}\ln^2(\sin \theta\cos \theta)\,d\theta=\int_0^{\frac{\pi}{2}}\ln^2\left(\frac{1}{2}\sin(2\theta)\right)\,d\theta$

Perform the change of variable $\displaystyle x=2\theta$,

\begin{align}L&=\frac{1}{2}\int_0^{\pi}\ln^2\left(\frac{1}{2}\sin\theta\right)\,d\theta\\ &=\frac{1}{2}\int_0^{\frac{\pi}{2}}\ln^2\left(\frac{1}{2}\sin\theta\right)\,d\theta+\frac{1}{2}\int_{\frac{\pi}{2}}^{\pi}\ln^2\left(\frac{1}{2}\sin\theta\right)\,d\theta\\ \end{align}

In the latter integral perform the change of variable $\displaystyle x=\pi-\theta$,

\begin{align} L&=\int_0^{\frac{\pi}{2}}\ln^2\left(\frac{1}{2}\sin\theta\right)\,d\theta\\ &=\int_0^{\frac{\pi}{2}}\left(\ln(\sin\theta)-\ln 2\right)^2\,d\theta\\ &=K-2\ln 2\int_0^{\frac{\pi}{2}}\ln(\sin \theta)\,d\theta+\frac{1}{2}\pi \ln^2 2 \end{align}

and it is well kwown that,

$\displaystyle \int_0^{\frac{\pi}{2}}\ln(\sin \theta)\,d\theta=-\frac{1}{2}\pi\ln 2$

Therefore,

$\displaystyle L=K+\frac{3}{2}\pi \ln^2 2$

Therefore,

\begin{align}K&=\frac{1}{3}\int_0^{\frac{\pi}{2}}\ln^2\left(\tan\theta\right)\,d\theta+\frac{1}{2}\pi\ln^2 2\\ \end{align}

Perform the change of variable $\displaystyle y=\tan x$,

\begin{align} K&=\frac{1}{3}\int_0^{\infty}\frac{\ln^2 x}{1+x^2}\,dx+\frac{1}{2}\pi\ln^2 2\\ &=\frac{1}{3}\int_0^{1}\frac{\ln^2 x}{1+x^2}\,dx+\frac{1}{3}\int_1^{\infty}\frac{\ln^2 x}{1+x^2}\,dx+\frac{1}{2}\pi\ln^2 2\\ \end{align}

In the latter integral perform the change of variable $\displaystyle y=\frac{1}{x}$,

\begin{align} K=\frac{2}{3}\int_0^{1}\frac{\ln^2 x}{1+x^2}\,dx+\frac{1}{2}\pi\ln^2 2\\ \end{align}

Therefore,

\begin{align} \boxed{J=\frac{16}{3}\int_0^{1}\frac{\ln^2 x}{1+x^2}\,dx+4\pi\ln^2 2}\\ \end{align}

but,

$\displaystyle \int_0^{1}\frac{\ln^2 x}{1+x^2}\,dx=2\beta(3)$

(Beta function of Dirichlet, https://en.wikipedia.org/wiki/Dirichlet_beta_function )

and it is well known that,

$\displaystyle \beta(3)=\frac{\pi^3}{32}$

(see, for example, https://math.stackexchange.com/a/613341/186817 )

Therefore,

$\boxed{\displaystyle J=\frac{\pi}{3}+4\pi\ln^2 2}$

PS: another useful link, Calculate this integral, $\int_0^{\infty}\frac{\ln^2x}{1+x^2}dx$