<s>[INST] Calculate $\int\left( \sqrt{\tan x}+\sqrt{\cot x}\right)dx$ How to calculate following integration?
$$\int\left( \sqrt{\tan x}+\sqrt{\cot x}\right)dx$$
 [/INST] Let $u=\tan{x}$; the integral becomes
$$\int \frac{du}{1+u^2} \left (\sqrt{u} + \frac{1}{\sqrt{u}}\right)$$
Now let $u=v^2$ and get for the integral on the right
$$\frac{du}{1+u^2} \left (\sqrt{u} + \frac{1}{\sqrt{u}}\right) = 2 \int dv \frac{1+v^2}{1+v^4}$$
which may be evaluated via partial fractions:
$$\begin{align}2 \int dv \frac{1+v^2}{1+v^4} &=  \int dv \left (\frac{1}{v^2-\sqrt{2} v+1} + \frac{1}{v^2+\sqrt{2} v+1} \right )\\ &=  \int dv \left (\frac{1}{(v-1/\sqrt{2})^2+1/2} + \frac{1}{(v+1/\sqrt{2})^2+1/2} \right)\end{align}$$
From here, you can use the standard integral
$$\int \frac{dy}{y^2+a^2} = \frac{1}{a} \arctan{\frac{y}{a}}$$
The intermediate result is
$$\begin{align}2\int dv \frac{1+v^2}{1+v^4} &=  \sqrt{2} \arctan{\frac{1-v^2}{\sqrt{2}v}} = \sqrt{2} \arctan{\frac{1- u}{\sqrt{2u}}} \end{align}$$
Put this altogether to get finally:
$$\int dx \: (\sqrt{\tan{x}} + \sqrt{\cot{x}})= \sqrt{2} \arctan{\left(\frac{1-\tan{x}}{\sqrt{2\tan{x}}}\right)}+C$$
where $C$ is a constant of integration.  You may check this result by taking its derivative.
</s>