# How to reduce $\int_0^{\pi/2}\frac{1-\sin x}{\cos^2x}\sqrt{\tan x}\,dx$ to complete elliptic integral?

I came across another old post concerning a definite integral whose closed form can be expressed with a complete elliptic integral:

$$I = \int_0^\infty \left(\sqrt{1+x^4} - x^2\right) \, dx = \frac1{6\sqrt\pi} \Gamma^2\left(\frac14\right) = \frac23 K\left(\frac1{\sqrt2}\right)$$

Q: How can we manipulate $$I$$ to obtain an explicit elliptic integral form?

Consider this part III in a series of similar self-imposed challenges. The goal is to remain in Trig-Land, if possible. I'm well aware of the existing solutions relying on beta and hypergeometric functions. NB: The titular integral is equivalent to that in the third line below. (Part I; part II; bonus post in the same spirit sans elliptic integral)

##### My attempt

\begin{align*} I &= \int_0^\infty \left(\sqrt{1+x^4} - x^2\right) \, dx \\ &= \int_0^\tfrac\pi2 \frac{\sec x - \tan x}{2\cos^2x \sqrt{\tan x}} \, dy & x\to\sqrt{\tan x} \\ &= \int_0^\tfrac\pi2 \sec x (\sec x - \tan x) \sqrt{\tan x} \, dx & \text{by parts} \\ &= \left\{\int_{-\tfrac\pi4}^0 + \int_0^\tfrac\pi4\right\} \frac{2 + \sqrt2 (\sin x - \cos x)}{(\sin x+\cos x)^2} \sqrt{\frac{1-\tan x}{1+\tan x}} \, dy & x\to\frac\pi4-x \\ &= 2\sqrt2 \int_0^\tfrac\pi4 \frac{\cos^2(2x)+2\sqrt2\cos x-\sqrt2\cos x\cos(2x) - 2}{\cos^2(2x) \sqrt{\cos(2x)}} \, dx & x\to-x \\ &= 2\sqrt2 \int_0^\tfrac\pi4 \left[1 - \frac{2+\sqrt2\cos x}{\left(1+\sqrt2\cos x\right)^2} \right] \, \frac{dx}{\sqrt{\cos(2x)}} & \text{partial fractions} \\ &= 2\sqrt2 \left(I_1 - I_2\right) \end{align*}

Not mentioned are applications of trig identities, which I think are easy enough for readers to deduce.

Next, denote $$Y=\sqrt{1-\frac12\sin^2y}$$. The first term is easy to deal with:

\begin{align*} I_1 &= \int_0^\tfrac\pi4 \frac{dy}{\sqrt{\cos(2x)}} \\ &= \int_0^\tfrac\pi4 \frac{dx}{\sqrt{1-2\sin^2x}} \\ &= \frac1{\sqrt2} \int_0^\tfrac\pi2 \frac{dy}Y & \sin x=\frac1{\sqrt2} \sin y \\ &= \frac1{\sqrt2} \, K\left(\frac1{\sqrt2}\right) \end{align*}

Performing the same transformation on the second term yields a more complicated integrand,

$$I_2 = \int_0^\tfrac\pi2 \frac{\sqrt2 + Y}{\left(1 + \sqrt2 Y\right)^2} \frac{dy}Y \tag{*}$$

This is where I'm currently stuck. It seems that, by some clever choice of adding net-zero terms to the numerator, we should be able to reduce $$(*)$$ to

$$\frac{\sqrt2}3 \int_0^\tfrac\pi2 \frac{dy}Y = \frac{\sqrt2}3 \, K\left(\frac1{\sqrt2}\right)$$

Rationalizing the denominator, we have

$$I_2 = \int_0^\tfrac\pi2 \frac{\sqrt2-3Y+2Y^3}{\cos^4y} \frac{dy}Y = \int_0^\tfrac\pi2 \frac{\sqrt2 - Y \left(1+\sin^2y\right)}{\cos^4y} \, \frac{dy}Y$$

Now, the integral of $$\dfrac{1+\sin^2y}{\cos^4y}$$ diverges, but I'm thinking there may be some vanishing function $$f$$ (in the sense $$J=\int_0^{\pi/2}f(y)\,dy=0$$) that will simultaneously "cancel out" the divergence and the factor of $$\cos^4y$$. That is,

$$I_2 = I_2 + J \equiv \frac{\sqrt2}3 \int_0^\tfrac\pi2 \frac{dy}Y$$

but whether such a function exists, I'm not sure.

• Which is explicitly the question? (1) How to show that the value of $I$ is the specified one? Or (2) How to compute the integral from the title? Or (3) How to compute the last integral in the chain, where we are stuck in a specific integral w.r.t. $dy$ involving an expression $Y=\sqrt{1-\frac 12\sin^2y}$, at many places? Would it be ok to use the algebraic setting (an elliptic curve is there, why not integrate on it?) and manage the computations in a quick manner (without splitting into Taylor series)? Are we constrained to remain in a "trigonometric world"? Commented Apr 12 at 0:25
• @dan_fulea I'm most interested in (3), that is, proceeding with the evaluation of $(*)$ to end up with the final integral containing $\frac{dy}Y$. How it's done isn't particularly important - e.g. I don't mind substituting out of trig with, say, $t=\sin y$ and working from there - as long as the connection between these two integral expressions is made clear. Commented Apr 12 at 2:13
• General solution cdn.discordapp.com/attachments/1145303787397992539/… Commented Apr 15 at 19:18

In this question (An integral related to $\Gamma(\tfrac14)^2$) we have seen that: \begin{align} \frac{1}{4}\int_{0}^{\infty}\frac{dt}{t^{3/4}\sqrt{1+t}}=K(\frac{1}{\sqrt{2}})\tag{1}. \end{align} In the other hand your integral is: \begin{align} I=\int_{0}^{\infty}(\sqrt{1+x^4}-x^2)dx=\frac{2}{3}\int_{0}^{\infty}\frac{dx}{\sqrt{1+x^4}}\\\overset{x=t^{1/4}}=\frac{1}{6}\int_{0}^{\infty}\frac{dt}{t^{3/4}\sqrt{1+t}}\tag{2}. \end{align} Where in the first step we have used: \begin{align} \int_{0}^{y}(\sqrt{1+x^4}-x^2)dx=\frac{2}{3}\int_{0}^{y}\frac{dx}{\sqrt{1+x^4}}+\frac{y\sqrt{1+y^4}}{3}-\frac{y^3}{3}\tag{3}. \end{align} Combining $$(1)$$ and $$(2)$$ then $$I=\frac{2}{3}K(\frac{1}{\sqrt{2}})$$.

First, fully rationalizing the denominator by multiplication of $$\dfrac YY$$ in $$I_2$$ and rewriting each $$\sin\to\cos$$ (for the sake of keeping unit coefficients in the square roots) leads to

\begin{align*} I_2 &= \int_0^\tfrac\pi2 \frac{2\sqrt{1+\cos^2y} - \left(1+\cos^2y\right)\left(2-\cos^2y\right)}{\cos^4y \left(1+\cos^2y\right)} \, dy \\ &= \underbrace{\int_0^\tfrac\pi2 \frac{dy}{1+\cos^2y}}_{=\tfrac\pi{2\sqrt2}} + \underbrace{\int_0^\tfrac\pi2 \frac{2\sqrt{1+\cos^2y} - 1 - \cos^2y}{\cos^4y \left(1+\cos^2y\right)} \, dy}_{I_3} \end{align*}

We can condense the numerator in $$I_3$$ to $$\left(1-\sqrt{1+\cos^2y}\right)^2$$. Expanding to partial fractions gives a sum of convergent integrals containing a few trivial terms that can be evaluated by elementary means as well as a few elliptic integrals.

\begin{align*} I_3 &= \int_0^\tfrac\pi2 \left(\sqrt{1+\cos^2y}-1\right)^2 \left(\frac1{\cos^2y} - \frac1{\cos^4y} - \frac1{1+\cos^2y}\right) \, dy \\ &= \left(\frac\pi2 + 2 \int_0^\tfrac\pi2 \frac{1-\sqrt{1+\cos^2y}}{\cos^2y} \, dy\right) - \int_0^\tfrac\pi2 \frac{\left(1-\sqrt{1+\cos^2y}\right)^2}{\cos^4y} \, dy \\ &\qquad - \left(\left(\frac12+\frac1{2\sqrt2}\right)\pi - 2 \int_0^\tfrac\pi2 \frac{dy}{\sqrt{1+\cos^2y}}\right) \\[2ex] \implies I_2 &= 2 \underbrace{\int_0^\tfrac\pi2 \frac{dy}{\sqrt{1+\cos^2y}}}_{\star} + 2 \underbrace{\int_0^\tfrac\pi2 \frac{1-\sqrt{1+\cos^2y}}{\cos^2y} \, dy}_{\star\star} - \underbrace{\int_0^\tfrac\pi2 \frac{\left(1-\sqrt{1+\cos^2y}\right)^2}{\cos^4y} \, dy}_{\star\star\star} \\ &= -\frac{\sqrt2}3 \, K\left(\frac1{\sqrt2}\right) + 2 \int_0^\tfrac\pi2 \sin^2y \sqrt{1+\cos^2y} \, dy \end{align*}

The last integral is evaluated here.

Some intermediate steps:

• $$\star$$ is immediate from the definition of $$K$$,

\begin{align*} \star &= \frac1{\sqrt2} \int_0^\tfrac\pi2 \frac{dy}Y = \frac1{\sqrt2} \, K\left(\frac1{\sqrt2}\right) \end{align*}

• $$\star\star$$ is evaluated by parts,

\begin{align*} \star\star &= \tan y\left(1 - \sqrt{1+\cos^2y}\right) \bigg|_0^\tfrac\pi2 - \int_0^\tfrac\pi2 \frac{\sin^2y}{\sqrt{1+\cos^2y}} \, dy \\ &= \int_0^\tfrac\pi2 \frac{-1+\cos^2y}{\sqrt{1+\cos^2y}} \, dy \\ &= \sqrt2 \int_0^\tfrac\pi2 \left(Y - \frac1Y\right) \, dy \\ &= \sqrt2 \, E\left(\frac1{\sqrt2}\right) - \sqrt2 \, K\left(\frac1{\sqrt2}\right) \end{align*}

• $$\star\star\star$$ is evaluated by parts three times,

\begin{align*} \star\star\star &= \frac13 \left(3\tan y+\tan^3y\right) \left(1-\sqrt{1+\cos^2y}\right)^2 \bigg|_0^\tfrac\pi2 \\ & \qquad -\frac23 \int_0^\tfrac\pi2 \left(2\sin^2y + \tan^2y\right) \left(\frac1{\sqrt{1+\cos^2y}} - 1\right) \, dy \\ &= \frac23 \int_0^\tfrac\pi2 \frac{\sin^2y}{\sqrt{1+\cos^2y}} \, dy - \frac43 \int_0^\tfrac\pi2 \frac{\sin^2y\cos^2y}{\left(1+\cos^2y\right)^{3/2}} \, dy \\ &= \frac{2\sqrt2}3 \int_0^\tfrac\pi2 \left(Y - \frac1Y\right) \, dy \\ &\qquad - \frac43 \left[\frac{\sin y \cos^3y}{\sqrt{1+\cos^2y}} \bigg|_0^\tfrac\pi2 + \int_0^\tfrac\pi2 \frac{3\cos^4y-2\cos^2y}{\sqrt{1+\cos^2y}} \, dy\right] \\ &= 2\sqrt2 \int_0^\tfrac\pi2 \left(Y - \frac1{3Y}\right)\,dy - 4 \int_0^\tfrac\pi2 \frac{\cos^4y}{\sqrt{1+\cos^2y}} \, dy \\ &= 2\sqrt2 \int_0^\tfrac\pi2 \left(Y - \frac1{3Y}\right)\,dy \\ &\qquad - 2 \left[\sin y \cos y \sqrt{1+\cos^2y} \bigg|_0^\tfrac\pi2 + \int_0^\tfrac\pi2 \sin^2y \sqrt{1+\cos^2y} \, dy\right] \\ &= 2\sqrt2 \int_0^\tfrac\pi2 \left(Y - \frac1{3Y}\right)\,dy - 2 \int_0^\tfrac\pi2 \sin^2y \sqrt{1+\cos^2y} \, dy \\ &= 2\sqrt2\,E\left(\frac1{\sqrt2}\right) - \frac{2\sqrt2}3 \, K\left(\frac1{\sqrt2}\right) - 2 \int_0^\tfrac\pi2 \sin^2y \sqrt{1+\cos^2y} \, dy \end{align*}