Evaluating the indefinite integral $ \int \sqrt{\tan x} ~ \mathrm{d}{x}. $ I have been having extreme difficulties with this integral. I would appreciate any and all help.
$$
\int \sqrt{\tan x} ~ \mathrm{d}{x}.
$$

Let $I = \int\sqrt{\tan x}\;\mathrm{d}x$ and $J = \int\sqrt{\cot x}\;\mathrm{d}x$.
Now $$\begin{align}I + J 
&= \int\left(\sqrt{\tan x} + \sqrt{\cot x}\right) \;\mathrm{d}x \\
&= \sqrt{2} \int\frac{\sin x + \cos x}{\sqrt{\sin 2x}} \;\mathrm{d}x \\[5pt]
&= \sqrt{2} \int\frac{(\sin x - \cos x)'}{\sqrt{1-(\sin x - \cos x)^2}} \;\mathrm{d}x \\[5pt]
&= \sqrt{2} \sin^{-1}(\sin x - \cos x) + \mathbb{C_1} \tag{1} \\
\end{align}$$
and $$\begin{align}I - J
&= \int\left(\sqrt{\tan x} - \sqrt{\cot x}\right) \;\mathrm{d}x \\
&= \sqrt{2} \int\frac{(\sin x - \cos x)}{\sqrt{\sin 2x}} \;\mathrm{d}x \\
&= -\sqrt{2} \int\frac{(\sin x + \cos x)'}{\sqrt{(\sin x + \cos x)^2 - 1}} \;\mathrm{d}x \\
&= -\sqrt{2} \ln\left|(\sin x + \cos x) + \sqrt{(\sin x + \cos x)^2 - 1}\right| + \mathbb{C_2} \tag{2} \\
\end{align}$$
Now, adding $(1)$ and $(2)$:
$$I = \frac{1}{\sqrt{2}} \sin^{-1}(\sin x - \cos x) - \frac{1}{\sqrt{2}} \ln\left|\sin x + \cos x + \sqrt{\sin 2x} \vphantom{x^{x^x}} \right| + \mathbb{C}$$
