Evaluate $\int_{0}^{\frac{\pi}{2}}\frac{dx}{\left(\sqrt{\sin x}+\sqrt{\cos x}\right)^2}$

\begin{align}I&=\int_{0}^{\frac{\pi}{2}}\frac{dx}{\left(\sqrt{\sin x}+\sqrt{\cos x}\right)^2}\\ &=\int_{0}^{\frac{\pi}{4}}\frac{dx}{\left(\sqrt{\sin x}+\sqrt{\cos x}\right)^2} +\int_{\frac{\pi}{4}}^{\frac{\pi}{2}}\frac{dx}{\left(\sqrt{\sin x}+\sqrt{\cos x}\right)^2}\\\end{align}

In the second integral perform the change of variable $y=\frac{\pi}{2}-x$,

\begin{align}I&=2\int_{0}^{\frac{\pi}{4}}\frac{dx}{\left(\sqrt{\sin x}+\sqrt{\cos x}\right)^2}\\ \end{align}

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

\begin{align} I&=2\int_{0}^{1}\frac{1}{(1+\sqrt{x})^2\sqrt{1+x^2}}\,dx\\\end{align}

Perform the change of variable $y=\dfrac{1-x}{1+x}$,

\begin{align}I&=\sqrt{2}\int_{0}^{1}\frac{1-\sqrt{1-x^2}}{x^2\sqrt{1+x^2}}\,dx\\ &=-\sqrt{2}\Big[\frac{1-\sqrt{1-x^2}}{x\sqrt{1+x^2}}\Big]_0^1-\sqrt{2}\int_0^1 \frac{\sqrt{1-x^2}-2}{\sqrt{1-x^2}(1+x^2)^{\frac{3}{2}}}\,dx\\ &=-1-\sqrt{2}\int_0^1 \frac{1}{(1+x^2)^{\frac{3}{2}}}\,dx+2\sqrt{2}\int_0^1 \frac{1}{\sqrt{1-x^2}(1+x^2)^{\frac{3}{2}}}\,dx\\ &=-1-\sqrt{2}\left[\frac{x}{\sqrt{1+x^2}}\right]_0^1+2\sqrt{2}\int_0^1 \frac{1}{\sqrt{1-x^2}(1+x^2)^{\frac{3}{2}}}\,dx\\ &=2\sqrt{2}\int_0^1 \frac{1}{\sqrt{1-x^2}(1+x^2)^{\frac{3}{2}}}\,dx-2\\ \end{align}

Perform the change of variable $y=\dfrac{1-x}{1+x}$,

\begin{align}I&=\int_0^1 \frac{x^2+1+2x}{\sqrt{x}(1+x^2)^{\frac32}}\,dx-2\\ &=\int_0^1 \frac{1}{\sqrt{x}\sqrt{1+x^2}}\,dx+2\int_0^1 \frac{\sqrt{x}}{(1+x^2)^{\frac32}}\,dx-2\\ \end{align}

Perform the change of variable $y=\sqrt{x}$ in both integrals,

\begin{align}I&=2\int_0^1 \frac{1}{\sqrt{1+x^4}}\,dx+4\int_0^1 \frac{x^2}{(1+x^4)^{\frac32}}\,dx-2\end{align}

\begin{align}A&=\int_0^1 \frac{1}{\sqrt{1+x^4}}\,dx\end{align}

Perform the change of variable $y=\frac{1}{x}$,

\begin{align}A&=\int_1^\infty \frac{1}{\sqrt{1+x^4}}\,dx=\int_0^\infty \frac{1}{\sqrt{1+x^4}}\,dx-\int_0^1 \frac{1}{\sqrt{1+x^4}}\,dx\\ &=\int_0^\infty \frac{1}{\sqrt{1+x^4}}\,dx-A \end{align}

Therefore,

\begin{align}A&=\frac{1}{2}\int_0^\infty \frac{1}{\sqrt{1+x^4}}\,dx\end{align}

In the same manner one obtains,

\begin{align}\int_0^1 \frac{x^2}{(1+x^4)^{\frac32}}\,dx&=\frac{1}{2}\int_0^\infty \frac{x^2}{(1+x^4)^{\frac32}}\,dx\end{align}

Therefore,

\begin{align}I&=\int_0^\infty \frac{1}{\sqrt{1+x^4}}\,dx+2\int_0^\infty \frac{x^2}{(1+x^4)^{\frac32}}\,dx-2\end{align}

Perform the change of variable $y=x^4$,

\begin{align}I&=\frac{1}{4}\int_0^\infty \frac{x^{-\frac34}}{(1+x)^{\frac12}}\,dx+\frac{1}{2}\int_0^\infty \frac{x^{-\frac14}}{(1+x)^{\frac32}}\,dx-2\\ &=\frac{1}{4}\text{B}\left(\frac{1}{4},\frac{1}{4}\right)+\frac{1}{2}\text{B}\left(\frac{3}{4},\frac{3}{4}\right)-2\\ &=\frac{1}{4}\times \frac{\Gamma^2\left(\frac{1}{4}\right)}{\Gamma\left(\frac{1}{2}\right)}+\frac{1}{2}\times \frac{\Gamma^2\left(\frac{3}{4}\right)}{\Gamma\left(\frac{3}{2}\right)}-2\\ &=\frac{1}{4}\times \frac{\Gamma^2\left(\frac{1}{4}\right)}{\Gamma\left(\frac{1}{2}\right)}+\frac{1}{2}\times \frac{\Gamma^2\left(\frac{3}{4}\right)}{\frac{1}{2}\Gamma\left(\frac{1}{2}\right)}-2\\ &=\frac{1}{4}\times \frac{\Gamma^2\left(\frac{1}{4}\right)}{\Gamma\left(\frac{1}{2}\right)}+\frac{\Gamma^2\left(\frac{3}{4}\right)}{\Gamma\left(\frac{1}{2}\right)}-2\\ \end{align}

It is well known (Euler's reflection formula) that,

\begin{align}\Gamma\left(\frac{1}{2}\right)=\sqrt{\pi}\end{align}

Therefore,

\begin{align}\boxed{I=\frac{\Gamma^2\left(\frac{1}{4}\right)}{4\sqrt{\pi}}+\frac{\Gamma^2\left(\frac{3}{4}\right)}{\sqrt{\pi}}-2}\end{align}

NB:

$\text{B}$ is the Euler beta function.