Evaluation of complete elliptic integrals $K(k) $ for $k=\tan(\pi/8),\sin(\pi/12)$

This is inspired from here. I will repeat some information from the linked question for the benefit of readers.


Let $k\in(0,1)$ and the elliptic integrals $K, E$ are defined as follows: $$K(k)=\int_{0}^{\pi/2}\frac{dx}{\sqrt{1 - k^{2}\sin^{2}x}},\,E(k)=\int_{0}^{\pi/2}\sqrt{1-k^{2}\sin^{2}x}\,dx\tag{1}$$ The number $k$ is called the modulus and a complementary modulus $k'$ is defined by $k'=\sqrt{1-k^{2}}$ and if the value of $k$ is available from context then the integrals $K(k), E(k), K(k'), E(k') $ are generally denoted by $K, E, K', E'$.

If $n$ is a positive rational number then it can be proved that there is a unique modulus $k$ such that $K'/K=\sqrt{n} $ and moreover this $k$ is an algebraic number. Such values of $k$ are famous and are called singular moduli and one may denote them by $k_{n} $ corresponding to the rational number $n$.

Chowla and Selberg proved in this paper that

Theorem: Let $k$ be a singular modulus. Then the elliptic integrals $K(k), E(k) $ can be expressed in terms of Gamma values at rational points and $\pi$.

The linked paper of Chowla and Selberg uses theory of quadratic forms and related complex analytic techniques to prove their theorem. On the other hand Ramanujan knew the evaluation of $K$ in terms of Gamma values and $\pi$ for some singular moduli $k$. In his classic paper Modular Equations and Approximations to $\pi$ he gave the evaluations for $n=1,2,3$ without proof. It is thus reasonable to assume that the evaluations are possible by remaining within the limits of real analysis methods at least for $n=1,2,3$. The case $n=1$ is covered in this answer.

My question concerns the cases $n=2,3$ for which $k=\tan(\pi/8),\sin(\pi/12)$ respectively:

Show that $$\int_{0}^{\pi/2}\frac{dx}{\sqrt{1-\tan^{2}(\pi/8)\sin^{2}x}}=\frac{\sqrt{\sqrt{2} +1} \Gamma (1/8)\Gamma (3/8)}{2^{13/4}\sqrt{\pi}}\tag{2}$$ and $$\int_{0}^{\pi/2}\frac{dx}{\sqrt{1-\sin^{2}(\pi/12)\sin^{2}x}}=\frac{3^{1/4}\Gamma ^{3}(1/3)}{2^{7/3}\pi}\tag{3}$$

Evaluation based on real analysis methods is desirable.


Update: I have managed to prove the above mentioned results using hints given in exercises from Borwein's Pi and the AGM (see my answer). But these methods are totally non-obvious and it is desirable to find solutions based on general techniques for evaluation of definite integrals.

Borwein's book was with me for a long time and these exercises lay dormant until I receieved a gentle push via user "Simply Beautiful Art"'s question linked above. Thanks to him for the same.


I finally found a solution for $k = \sin(\pi/12)$. It is taken from an exercise in Borwein's Pi and the AGM.

Let's start with the integral $$I(a, b) = \int_{-a}^{a}\frac{dx}{\sqrt{(a^{2} - x^{2})(b^{2} + x^{2})}}\tag{1}$$ which is equal to $$\frac{2}{\sqrt{a^{2} + b^{2}}}K\left(\frac{a}{\sqrt{a^{2} + b^{2}}}\right)\tag{2}$$ Equivalence of $I(a, b)$ with $(2)$ can be seen by writing $K$ as \begin{align} K(k) &= \int_{0}^{\pi/2}\frac{dx}{\sqrt{1 - k^{2}\cos^{2}x}}\notag\\ &= \int_{0}^{\pi/2}\frac{dx}{\sqrt{1 - k^{2} + k^{2}\sin^{2}x}}\notag\\ &=\int_{0}^{1}\frac{dt}{\sqrt{(1 - t^{2})(1 - k^{2} + k^{2}t^{2})}}\notag\\ \end{align} Putting $k = a/\sqrt{a^{2} + b^{2}}$ we can see that $$K\left(\frac{a}{\sqrt{a^{2} + b^{2}}}\right) = \sqrt{a^{2} + b^{2}}\int_{0}^{1}\frac{dt}{\sqrt{(1 - t^{2})(b^{2} + a^{2}t^{2})}}$$ and using substitution $x = at$ we get the link between $(1)$ and $(2)$.

Next we use the substitution $x = (1/t) - a$ in $(1)$ to get $$I(a, b) = \int_{1/2a}^{\infty}\frac{dt}{\sqrt{(2at - 1)((a^{2} + b^{2})t^{2} - 2at + 1)}}$$ The expression in square root can be expressed as $$2a(a^{2} + b^{2})t^{3} - (5a^{2} + b^{2})t^{2} + 4at - 1$$ and using the substitution $$t = x + \frac{5a^{2} + b^{2}}{6a(a^{2} + b^{2})}$$ the integral is transformed into $$I(a, b) = \int_{e}^{\infty}\frac{dx}{\sqrt{4x^{3} - g_{2}x - g_{3}}}\tag{3}$$ where $$g_{2} = \frac{(a^{2} - b^{2})^{2}}{12} - a^{2}b^{2},\, g_{3} = -\frac{(a^{2} - b^{2})\{(a^{2} - b^{2})^{2} + 36a^{2}b^{2}\}}{216}\tag{4}$$ and $e$ is the root of the cubic equation $4x^{3} - g_{2}x - g_{3} = 0$.

Next step is to put $g_{2} = 0$ so that $12a^{2}b^{2} = (a^{2} - b^{2})^{2}$ which gives $$a^{2} - b^{2} = -3(2g_{3})^{1/3}, a^{2} + b^{2} = 2\sqrt{3}(2|g_{3}|)^{1/3}\tag{5}$$ For our case we need to set $g_{3} = 1/2$ so that the root $e = 1/2$ and then we have $$a^{2} + b^{2} = 2\sqrt{3}, a^{2} - b^{2} = -3$$ so that $$\frac{a}{\sqrt{a^{2} + b^{2}}} = \frac{\sqrt{3} - 1}{2\sqrt{2}} = \sin(\pi/12)$$ From $(1), (2), (3)$ and above values of $a, b$ it follows that $$K(k) = \frac{3^{1/4}}{2}\int_{1}^{\infty}\frac{dx}{\sqrt{x^{3} - 1}}$$ And putting $x^{3} = 1/t$ we get $$K(k) = \frac{3^{1/4}}{6}\int_{0}^{1}t^{-5/6}(1 - t)^{-1/2}\,dt = \frac{3^{1/4}}{6}\frac{\Gamma(1/6)\Gamma(1/2)}{\Gamma(2/3)}$$ This can be expressed in terms of $\Gamma(1/3)$ only (via duplication and reflection formulas) to give the desired form.


I must say that the above solution is totally non-obvious and without the hints in the exercise it does not appear possible to arrive at this solution. The value of $K(\sin(\pi/12))$ was first obtained by Legendre using a similar non-obvious approach.


Borwein's book provides the evaluation of $K(\tan(\pi/8))$ as an exercise in a later chapter. But this is based on the representation of $2K(k)/\pi$ as the hypergeometric function ${}_{2}F_{1}(1/2,1/2;1;k^{2})$. To simplify typing we will use $F$ instead of ${}_{2}F_{1}$ in what follows.

The following two hypergeometric transformations are needed to create the magic \begin{align} &F(a, b; a - b + 1; x)\notag\\ &\,\,\,\,\,\,\,\,\,\,\,\,= (1 - x)^{1 - 2b}(1 + x)^{2b - a - 1}F\left(\frac{a - 2b + 1}{2}, \frac{a - 2b + 2}{2}; a - b + 1; \frac{4x}{(1 + x)^{2}}\right)\tag{6} \end{align} and $$F\left(a, b; a + b + \frac{1}{2}; 4x(1 - x)\right) = F\left(2a, 2b; a + b + \frac{1}{2}; x\right)\tag{7}$$ Equation $(7)$ is by Kummer and proved here. Equation $(6)$ can be proved in a similar manner but with more difficulty. We start with the equation $$\frac{2K}{\pi} = F\left(\frac{1}{2},\frac{1}{2};1;k^{2}\right)$$ and put $a=b=1/2, x = k^{2}$ in $(6)$ to get $$\frac{2K}{\pi}=(1 + k^{2})^{-1/2}F\left(\frac{1}{4},\frac{3}{4};1;\frac{4k^{2}}{(1 + k^{2})^{2}}\right)$$ Using $a = 1/8, b = 3/8, x = 4k^{2}/(1 + k^{2})^{2}$ in $(7)$ we get $$\frac{2K}{\pi}=(1 + k^{2})^{-1/2}F\left(\frac{1}{8},\frac{3}{8};1; X\right)\tag{8}$$ where $$X = 4x(1 - x) = \frac{16k^{2}(1 - k^{2})^{2}}{(1 + k^{2})^{4}} = \left(\frac{4kk'^{2}}{(1 + k^{2})^{2}}\right)^{2}$$ It's time to put $k = \tan(\pi/8) = \sqrt{2} - 1$ to get $X = 1$ (check this!). And thus we finally get $$K(\tan(\pi/8)) = \frac{\pi}{2\sqrt{4 - 2\sqrt{2}}}F(1/8, 3/8;1;1)$$ And then we use the formula $$F(a,b;c;1) = \frac{\Gamma(c)\Gamma(c - a - b)}{\Gamma(c - a)\Gamma(c - b)}\tag{9}$$ to get $$K(\tan(\pi/8)) = \frac{\sqrt{\sqrt{2} + 1}\pi}{2^{7/4}}\cdot\frac{\Gamma(1/2)}{\Gamma(7/8)\Gamma(5/8)}$$ which simplifies to the given form using the reflection formula and $\Gamma(1/2) = \sqrt{\pi}$.


The transformation $(6)$ is non-obvious and it is used by Borwein brothers to link Ramanujan's alternative theory of theta functions (those dealing with $F(1/4, 3/4;1; x)$) with the standard theory (dealing with $F(1/2, 1/2;1;x)$). This is a key step in Borwein's proof of Ramanujan's famous series for $1/\pi$ and this particular development is well covered in my blog post.