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?
 A: 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]$$
A: 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}$
A: 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. 
A: 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}$.
A: 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)!}$$ 
A: \begin{align}
\int_0^{\Large\frac{\pi}{4}} \sqrt{\tan x} \sqrt{1-\tan x}\,\,dx&=\int_0^1\frac{\sqrt{y(1-y)}}{1+y^2}\,dy\quad\Rightarrow\quad y=\tan x\\
&=\int_0^\infty\frac{\sqrt{t}}{(1+t)(1+2t+2t^2)}\,dt\quad\Rightarrow\quad t=\frac{y}{1-y}\\
&=\int_0^\infty\frac{2z^2}{(1+z^2)(1+2z^2+2z^4)}\,dz\quad\Rightarrow\quad z^2=t\\
&=2\int_0^\infty\left[\frac{2z^2}{1+2z^2+2z^4}+\frac{1}{1+2z^2+2z^4}-\frac{1}{1+z^2}\right]\,dz\\
&=\int_{-\infty}^\infty\left[\frac{2z^2}{1+2z^2+2z^4}+\frac{1}{1+2z^2+2z^4}-\frac{1}{1+z^2}\right]\,dz\\
&=I_1+I_2-\pi
\end{align}

\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).
\begin{equation}
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}}
\end{equation}

Combine all the results together, we finally get

\begin{equation}
\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
\end{equation}

A: 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
$$
A: 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)$ 
