# Evaluation of $\int_0^{\pi/4} \sqrt{\tan x} \sqrt{1-\tan x}\,\,dx$

How to evaluate the following integral $$\int_0^{\pi/4} \sqrt{\tan x} \sqrt{1-\tan x}\,\,dx$$ It looks like beta function but Wolfram Alpha cannot evaluate it. So, I computed the numerical value of integral above to 70 digits using Wolfram Alpha and I used the result to find its closed-form. The possible candidate closed-form from Wolfram Alpha is $$\pi\sqrt{\frac{1+\sqrt{2}}{2}}-\pi$$ Is this true? If so, how to prove it?

\begin{align} I_1 &=\int_{-\infty}^\infty\frac{2z^2}{1+2z^2+2z^4}\,dz\\ &=\int_{-\infty}^\infty\frac{1}{z^2+\frac{1}{2z^2}+1}\,dz\\ &=\int_{-\infty}^\infty\frac{1}{\left(z-\frac{1}{\sqrt{2}z}\right)^2+1+\sqrt{2}}\,dz\\ &=\int_{-\infty}^\infty\frac{1}{z^2+1+\sqrt{2}}\,dz\\ &=\frac{\pi}{\sqrt{1+\sqrt{2}}} \end{align} where the 4th line we use identity

\begin{align} \int_{-\infty}^\infty f\left(x\right)\,dx=\int_{-\infty}^\infty f\left(x-\frac{a}{x}\right)\,dx\qquad,\qquad\text{for }\, a>0. \end{align}

The proof can be seen in my answer here. $I_2$ can be proved in similar manner (see user111187's answer). $$I_2=\frac{1}{2}\int_{-\infty}^\infty\frac{1}{z^4+z^2+\frac{1}{2}}\,dz=\pi\sqrt{\frac{\sqrt{2}-1}{2}}$$

Combine all the results together, we finally get

$$\int_0^{\Large\frac{\pi}{4}} \sqrt{\tan x} \sqrt{1-\tan x}\,\,dx=\frac{\pi}{\sqrt[4]{2}}\sqrt{\frac{2+\sqrt{2}}{2}}-\pi$$

• Hey! Finally you back princess! +1 (>‿◠)✌ Oct 24, 2014 at 15:21
• An easy method to calculate $I_1$ and $I_2$ without residue calculus is outlined in my answer here: math.stackexchange.com/a/785213/111187 Oct 24, 2014 at 17:02
• @user111187 Thanks for sharing that. Really nice trick. Please post your answer, it's okay using mine step. Feel free (͡• ͜ʖ ͡•) Oct 24, 2014 at 17:17
• @user111187 Because you didn't post your solution, so I decided it to edit my answer using your formula for evaluating $I_2$. I hope you don't mind (❛‿❛✿̶̥̥) Oct 26, 2014 at 14:45

Here is a complex analysis approach. Integrate $$f(z)=\frac{\sqrt{z}\sqrt{z-1}}{z^2+1}=\frac{|z|^\frac{1}{2}|z-1|^\frac{1}{2}e^{i\varphi}}{z^2+1}$$ where $\varphi=\dfrac{1}{2}\left(\arg{z}+\arg(z-1)\right)$, $0\le \arg{z}, \arg(z-1)\le 2\pi$, along a dumbbell contour. Just above $[0,1]$, $\varphi=\dfrac{\pi}{2}$, and just below $[0,1]$, $\varphi=\dfrac{3\pi}{2}$. So the contour integral is \begin{align} 2i\int^1_0\frac{\sqrt{x}\sqrt{1-x}}{1+x^2}{\rm d}x =&2\pi i\left[\operatorname*{Res}_{z=i}f(z)+\operatorname*{Res}_{z=-i}f(z)-\operatorname*{Res}_{z=0}\frac{f(z^{-1})}{z^2}\right]\\ =&2\pi i\left[\frac{\sqrt[4]{2}}{2i}e^{i5\pi/8}-\frac{\sqrt[4]{2}}{2i}e^{i11\pi/8}-1\right]\\ =&2\pi i\left[\frac{\sqrt[4]{2}}{2i}\left(e^{i3\pi/8}-e^{-i3\pi/8}\right)-1\right]\\ =&2\pi i\left[\sqrt[4]{2}\sin\left(\frac{3\pi}{8}\right)-1\right] \end{align} Therefore $$\int^\frac{\pi}{4}_0\sqrt{\tan{x}-\tan^2{x}}\ {\rm d}x=\int^1_0\frac{\sqrt{x}\sqrt{1-x}}{1+x^2}{\rm d}x=\pi\left[\sqrt[4]{2}\sin\left(\frac{3\pi}{8}\right)-1\right]$$

• Thanks for your answer. I really appreciate it, but I don't know anything about complex analysis. +1 anyway :-) Oct 26, 2014 at 10:02
• It turns out we don't need use a complex analysis approach. I'm able to use a real analysis method only (✿◠‿◠) Oct 26, 2014 at 14:47
• @Anastasiya-Romanova I think this is purely a matter of personal preference. Though both real and complex methods are perfectly viable, I prefer using contour integration for this integral simply because I find it cleaner and more succint :) Oct 26, 2014 at 14:55
• Ya, you're right. It's only matter of personal preference. I said that since I haven't learned this method yet. Well, I've learned about the use of semicircular contour but only a little. I think your answer is also nice (although I don't completely understand it (─‿‿─)). Anyway, maybe you're interested in answering this OP of mine: Integral Contest. I have a strong feeling you can answer it ☜(ˆ▿ˆc) Oct 26, 2014 at 15:04
• @Anastasiya-Romanova That is indeed an interesting problem. I will try to work out a solution if I can. Oct 26, 2014 at 15:36

To continue the work of Anastasiya-Romanova but not using complex analysis

For $I_1$:

Notice: $p(z)=1+2z^2+2z^4=2\Big(z^2+az+b\Big)\Big(z^2-az+b\Big)$

where $a=\sqrt{\sqrt{2}-1}$ and $b=\dfrac{\sqrt{2}}{2}$

Therefore:

$f(z)=\displaystyle \dfrac{2z^2}{1+2z^2+2z^4}=\dfrac{z}{2a\Big(z^2-az+b\Big)}-\dfrac{z}{2a\Big(z^2+az+b\Big)}$ $f(z)=\dfrac{2z-a}{4a\Big(z^2-az+b\Big)}-\dfrac{2z+a}{4a\Big(z^2+az+b\Big)}+\dfrac{1}{4\Big(z^2-az+b\Big)}+\dfrac{1}{4\Big(z^2+az+b\Big)}$

Let $c=b-\dfrac{a^2}{4}$, $c>0$

Therefore:

$f(z)=\dfrac{2z-a}{4a\Big(z^2-az+b\Big)}-\dfrac{2z+a}{4a\Big(z^2+az+b\Big)}+\dfrac{1}{4\Big(\big(z-\tfrac{a}{2}\big)^2+c\Big)}+\dfrac{1}{4\Big(\big(z+\tfrac{a}{2}\big)^2+c\Big)}$

So a primitive of $\displaystyle \dfrac{2z}{1+2z^2+2z^4}$ is:

$\dfrac{1}{4a}\log\Big(\dfrac{z^2-az+b}{z^2+az+b}\Big)+\dfrac{1}{4\sqrt{c}}\arctan\Big(\dfrac{z-\tfrac{a}{2}}{\sqrt{c}}\Big)+\dfrac{1}{4\sqrt{c}}\arctan\Big(\dfrac{z+\tfrac{a}{2}}{\sqrt{c}}\Big)$

(think about derivative of $\log(u(x))$ )

Therefore:

$\displaystyle \int_{-\infty}^{+\infty}\dfrac{2x^2dx}{1+2x^2+2x^4}=\dfrac{\pi}{2\sqrt{c}}=\pi\sqrt{\sqrt{2}-1}$

To compute $I_2$ start performing change of variable $u=\dfrac{1}{x}$ , the function to integrate becomes $\dfrac{x^2}{x^4p\Big(\dfrac{1}{x}\Big)}$

$q(x)=x^4p\Big(\dfrac{1}{x}\Big)$

$q(x)=2x^4\Big(\dfrac{1}{x^2}+\dfrac{a}{x}+b\Big)\Big(\dfrac{1}{x^2}-\dfrac{a}{x}+b\Big)$

$q(x)=2(1+ax+bx^2)(1-ax+bx^2)$

$q(x)=2b^2\Big(x^2+\dfrac{a}{b}x+\dfrac{1}{b}\Big)\Big(x^2-\dfrac{a}{b}x+\dfrac{1}{b}\Big)$

The new $a,b$ are respectively $\dfrac{a}{b},\dfrac{1}{b}$ and there is a new $c$.

Therefore:

$\displaystyle \int_{-\infty}^{+\infty}\dfrac{dx}{1+2x^2+2x^4}=\dfrac{2}{b^2}\times \dfrac{\pi}{2\sqrt{c}}=\dfrac{\pi}{b^2\sqrt{c}}=\pi\dfrac{\sqrt{2}}{2}\sqrt{\sqrt{2}-1}$

• Did you answer continue Anastasiya's work? +1 anyway Oct 25, 2014 at 7:39

That's just a start, but using the change of variable:

$$u = \sqrt{\tan(x)}\quad\Rightarrow\quad\mathrm du = \frac{1+u^4}{2u}\mathrm dx,$$ you get:

$$I= 2\int_0^1 \frac{u^2\sqrt{1-u^2}}{1+u^4}\mathrm du$$

Now, let: $u= \sin(t)\Rightarrow\mathrm du = \cos(t)\mathrm dt$

$$I= 2\int_0^{\frac{\pi}{2}} \frac{\sin^2(t)\cos^2(t)}{1+\sin^4(t)}\mathrm dt$$

Now replacing the $\cos$ will give you:

$$I = 2\Bigl(\int_0^{\frac{\pi}{2}} {\frac{1+\sin^2(t)}{1+\sin^4(t)}\mathrm dt}\Bigr) -\pi$$

So here is the $-\pi$ :), now you can work on the other integral that might be easier to deal with. let's call it $I_1$.

Edit :

Now use : $v = \tan(t)$ -> $dv = \frac{1}{\cos^2(t)}dt$

$$I_1 = \int_0^{+\infty} \frac{cos^2(t)*(1+sin^2(t)}{1+sin^4(t)} du = \int_0^{+\infty} \frac{cos^4(t)*(1+2*u^2)}{1+sin^4(t)} du$$

Hence : $$I_1 = \int_0^{+\infty} \frac{1+2*u^2}{u^4+(1+u^2)^2} du$$

Now : $u^4 + (1+u^2)^2 = 2*u^4 +2*u^2 + 1 = \frac{1}{2}*(4*u^4+4*u^2 +2) = \frac{1}{2}*(1+ (2*u^2+1)^2)$

Thus giving : $$I_1 = \int_0^{+\infty} \frac{1+2u^2}{1+(1+2u^2)^2} du$$

Now this one is easier to treat I think.

• Maybe you don't like to hear that, but to me the last integral screams "residue theorem" ;) Oct 24, 2014 at 13:27
• Ha ha, maybe just so :) . It's a very good technic to use, that I don't master well however. I like real analysis, I can't help myself Oct 24, 2014 at 13:28
• Thanks. +1 for your effort :-) Oct 24, 2014 at 14:03
• I'm not done yet :) Oct 24, 2014 at 14:04

The result happens to coincide with the conjectured form: $$\mathcal I=\left(\sqrt[4]{2}\,\cos\frac{\pi}{8}-1\right)\pi.$$

Derivation: make the change of variables $t=\tan x$. This transforms the integral into $$\mathcal I=\int_0^1\frac{\sqrt{t(1-t)}}{1+t^2}dt$$ Now since we have a mix of rational function with only square roots of a quadratic polynomial, the antiderivative can be found in elementary functions using a suitable rational change of variables, e.g. $2t-1=\frac{\lambda-\lambda^{-1}}{2i}$.

• I've tried this one, didn't get it working well.. Oct 24, 2014 at 13:37
• Oh Jesus, not Cleo's style answer again... Oct 24, 2014 at 13:37
• Does it? I've tried it before I posted my answer and we don't get something very pretty, at least it doesn't look pretty. There is a root at the numerator and a denominator with a square. Is it straightforward from this point? Oct 24, 2014 at 13:41
• Ah ok, thx :) . I thought I was missing some obvious steps.. Oct 24, 2014 at 13:47

I have got a series expansion, though do not know if it of any use getting a closed form expression. Substituting $z=\tan x$

$$I=\int_{0}^1 \dfrac{z^{1/2}(1-z)^{1/2}}{1+z^2}dz=\sum_{k=0}^\infty (-1)^k\int_{0}^1z^{1/2+2k}(1-z)^{1/2}dz\\=\sum_{k=0}^{\infty}(-1)^k\beta\left(2k+3/2,3/2\right)=\dfrac{\sqrt{\pi}}{2}\sum_{k=0}^{\infty}(-1)^k \dfrac{\Gamma(2k+3/2)}{\Gamma(2k+3)}\\=\dfrac{\pi}{2}\sum_{k=0}^{\infty}(-1)^k\frac{(4k+2)!}{2^{2k+1}(2k+1)!(2k+3)!}$$

• Thanks. +1 for your effort :-) Oct 24, 2014 at 14:02
• Hoped that the effort could find a more fruitful solution :-) Oct 24, 2014 at 14:05

To get rid of both square root, I use the substitution$$\tan x = \sin^2\theta$$. Then we rewrite the integral I as $$\begin{array}{l} \displaystyle I=\int_{0}^{\frac{\pi}{2}} \sin \theta \sqrt{1-\sin ^{2} \theta} \cdot\frac{2 \sin \theta \cos \theta d \theta}{1+\sin ^{4} \theta} \\ =2 \displaystyle \int_{0}^{\frac{\pi}{2}} \dfrac{\sin ^{2} \theta \cos ^{2} \theta}{1+\sin ^{4} \theta} d \theta. \end{array}$$

Applying the identity $$\cos^2x=1-\sin^2x$$ yields $$I= 2 \underbrace{\int_{0}^{\frac{\pi}{2}} \frac{1+\sin ^{2} \theta}{1+\sin ^{4} \theta} d \theta}_{J}-\pi$$

$$J=2 \int_{0}^{\frac{\pi}{2}} \frac{\sec ^{2} \theta\left(\sec ^{2} \theta+\tan ^{2} \theta\right)}{\sec ^{4} \theta+\tan ^{4} \theta} d \theta$$

Letting $$\tan \theta \mapsto t$$, we have $$J=2 \int_{0}^{\infty} \frac{1+2 t^{2}}{2 t^{4}+2 t^{2}+1} d t \\ =\int_{0}^{\infty} \frac{1+2 t^{2}}{t^{4}+t^{2}+\frac{1}{2}} d t\\ =\int_{0}^{\infty} \frac{2+\frac{1}{t^{2}}}{t^{2}+\frac{1}{2 t^{2}}+1} d t$$

Using the identity $$\displaystyle 2+\frac{1}{t^{2}}=\frac{2+\sqrt{2}}{2}\left(1+\frac{1}{\sqrt{2} t^{2}}\right)+\frac{2-\sqrt{2}}{2}\left(1-\frac{1}{\sqrt{2} t^{2}}\right)$$ yields $$\displaystyle J=\frac{2+\sqrt{2}}{2} \int_{0}^{\infty} \frac{d\left(t-\frac{1}{\sqrt{2} t}\right)}{\left(t-\frac{1}{\sqrt{2}t}\right)^{2}+(1+\sqrt{2})}+\frac{2-\sqrt{2}}{2} \int_{0}^{\infty} \frac{d\left(t+\frac{1}{\sqrt{2} t}\right)}{\left(t+\frac{1}{\sqrt{2}t}\right) ^{2} -(\sqrt{2}-1)}$$ $$=\frac{2 +\sqrt 2}{2 \sqrt{1+\sqrt{2}}} \left[\tan ^{-1}\left(\frac{t-\frac{1}{\sqrt{2} t}}{\sqrt{1+\sqrt{2}}}\right)\right]_{0}^{\infty}+\frac{2-\sqrt{2}}{4 \sqrt{\sqrt{2}-1}} \ln \left|\frac{t^{2}-t \sqrt{\sqrt{2}-1}+1}{t^{2}+t \sqrt{\sqrt{2}-1}+1}\right|_{0}^{\infty} \\$$

$$\displaystyle \qquad\qquad =\frac{2+\sqrt{2}}{2 \sqrt{1+\sqrt{2}}} \pi \\ \displaystyle \qquad\qquad =\sqrt{\frac{1}{2}+\frac{1}{\sqrt{2}}} \pi$$

Finally, we can conclude that $$I= \left(\sqrt{\frac{1}{2}+\frac{1}{\sqrt{2}}}-1\right) \pi$$

Here I present a completely elementary proof using only high school level techniques.

With the obvious substitution $\displaystyle \large t = \tan{x}$

We proceed as follows:

Using the Euler Substitution of the third kind, the following substitution is obtained:

$\displaystyle \large \sqrt{t-t^2} = tz \Rightarrow t = \frac{1}{1+z^2}$

$\displaystyle \large \text{d}t = \frac{-2z \, \text{d}z}{(1+z^2)^2}$

The borders change from $\displaystyle \large (0 \to 1)_t$ to $\displaystyle \large (\infty \to 0)_z$, and note the negative from the differential element flips this back into more "sensible" borders

The computation of the transform is tedious algebra and I will omit said details.

$\displaystyle \large \int_0^{\frac{\pi}{4}} \sqrt{\tan{x}}\sqrt{1-\tan{x}} \text{d}x = 2 \int_0^\infty \frac{z^2 \, \text{d}z}{(z^4+2z^2+2)(z^2+1)}$

It is easy to show that:

$\displaystyle \large \frac{z^2}{(z^4+2z^2+2)(1+z^2)} \equiv \frac{z^2+2}{z^4+2z^2+2} - \frac{1}{1+z^2}$

Simplifying:

$\displaystyle \large \int_0^{\frac{\pi}{4}} \sqrt{\tan{x}}\sqrt{1-\tan{x}} \text{d}x = 2 \int_0^\infty \frac{(z^2 + 2) \, \text{d}z}{z^4+2z^2+2} - \pi$

With the simultaneous substitutions $\displaystyle \large z = \frac{\sqrt[4]{2}}{u}$ and $\displaystyle \large z = \sqrt[4]{2}u$, and averaging, the integral is reduced to:

$\displaystyle \large \frac{1+\sqrt{2}}{\sqrt[4]{2}} \int_0^\infty \frac{(u^2+1) \, \text{d}u}{u^4+\sqrt{2}u^2+1}$

The substitution $\displaystyle \large v = u - \frac{1}{u}$ bijects the interval $\displaystyle \large (0,\infty)_u \mapsto (-\infty, \infty)_v$ and the integral is reduced to:

$\displaystyle \large \frac{1+\sqrt{2}}{\sqrt[4]{2}} \int_{-\infty}^\infty \frac{\text{d}v}{v^2+2+\sqrt{2}} - \pi = \pi \left(\frac{1+\sqrt{2}}{\sqrt{2(1+\sqrt{2})}} - 1 \right) = \pi \left(\sqrt{\frac{1+\sqrt{2}}{2}} - 1\right)$