### Integral of square root of tangent x

Evaluate $\int \sqrt{\tan x} \; dx$

Substitute $u^2 = \tan x$, then we have

$2u\; du = \sec^2 x \; dx = (1 + \tan^2 x) \; dx = (1 + u^4)\; dx$

or, $dx = \frac{2u}{1+u^4}\; du$

So,$\int \sqrt{\tan x} \; dx$

$= \int \frac{2u^2}{1+u^4} \; du$

$\frac{2u^2}{1+u^4} = \frac{2u^2}{(u^2 + 1)^2 - 2u^2}$

$= \frac{2u^2}{(u^2 + 1 - \sqrt{2}u)(u^2 + 1 + \sqrt{2}u)}$

$= \frac{1}{\sqrt{2}} \left( \frac{u}{u^2 + 1 - \sqrt{2}u} - \frac{u}{u^2 + 1 + \sqrt{2}u} \right)$

$= \frac{1}{\sqrt{2}} \left( \frac{u}{(u - \frac{1}{\sqrt{2}})^2 + \frac{1}{2}} - \frac{u}{(u + \frac{1}{\sqrt{2}})^2 + \frac{1}{2}} \right)$

Substitute $s = u - \frac{1}{\sqrt{2}}$ or, $ds = du$ and $t = u + \frac{1}{\sqrt{2}}$ or, $dt = du$ we get

$\frac{1}{\sqrt{2}} \left( \frac{u}{(u - \frac{1}{\sqrt{2}})^2 + \frac{1}{2}} - \frac{u}{(u + \frac{1}{\sqrt{2}})^2 + \frac{1}{2}} \right)$

$= \frac{1}{\sqrt{2}} \left( \frac{s +\frac{1}{\sqrt{2}}}{s^2 + \frac{1}{2}} - \frac{t-\frac{1}{\sqrt{2}}}{t^2 + \frac{1}{2}} \right)$

$= \frac{1}{2\sqrt{2}} \left( \frac{2s}{s^2 + \frac{1}{2}} - \frac{2t}{t^2 + \frac{1}{2}} \right) + \frac{1}{2} \left( \frac{1}{s^2 + \frac{1}{2}} + \frac{1}{t^2 + \frac{1}{2}} \right)$

So, $\int \sqrt{\tan x} \; dx$

$= \frac{1}{2\sqrt{2}} \ln\left( \frac{s^2 + \frac{1}{2}}{t^2 + \frac{1}{2}} \right) + \sqrt{2} \left( \tan^{-1} (\sqrt{2}s) + \tan^{-1} (\sqrt{2}t) \right) + C$

$= \frac{1}{2\sqrt{2}} \ln\left( \frac{u^2 -\sqrt{2}u+ 1} {u^2 + \sqrt{2} u + 1} \right) + \sqrt{2} \left( \tan^{-1} (\sqrt{2}u - 1) + \tan^{-1} (\sqrt{2}u + 1) \right) + C$

$= \frac{1}{2\sqrt{2}} \ln\left( \frac{\tan x -\sqrt{2}\tan x+ 1} {\tan x + \sqrt{2} \tan x + 1} \right)$

$+ \sqrt{2} \left( \tan^{-1} (\sqrt{2}\tan x - 1) + \tan^{-1} (\sqrt{2}\tan x + 1) \right) + C$