Calculate $\int\left( \sqrt{\tan x}+\sqrt{\cot x}\right)dx$ [duplicate]
How to calculate following integration?
$$\int\left( \sqrt{\tan x}+\sqrt{\cot x}\right)dx$$
Solution 1:
$$I=\int\left( \sqrt{\tan x}+\sqrt{\cot x}\right)dx$$
$$=\int \frac{\sin x+\cos x}{\sqrt{\sin x\cos x}} dx$$
Putting $\sin x-\cos x=u,$ $du=(\cos x+\sin x)dx, u^2=1-2\sin x\cos x,\sin x\cos x=\frac{u^2-1}2$
$$I=\int \frac{\sqrt 2du }{\sqrt{1-u^2}}=\sqrt 2\arcsin u+C=\sqrt 2\arcsin(\sin x-\cos x)+C$$ where $C$ is an arbitrary constant for indefinite integral.
Solution 2:
Substitute $\tan(x)=u=e^{2t}$: $$ \begin{align} \int\left(\sqrt{\tan(x)}+\sqrt{\cot(x)}\right)\,\mathrm{d}x &=\int\left(u^{1/2}+u^{-1/2}\right)\,\frac{\mathrm{d}u}{1+u^2}\\ &=\int\frac{u^{1/2}+u^{-1/2}}{u+u^{-1}}\frac{\mathrm{d}u}{u}\\ &=\int\frac{\cosh(t)}{\cosh(2t)}2\,\mathrm{d}t\\ &=\int\frac2{\cosh(2t)}\mathrm{d}\sinh(t)\\ &=\int\frac{\sqrt2}{1+2\sinh^2(t)}\mathrm{d}\sqrt2\sinh(t)\\ &=\sqrt2\arctan(\sqrt2\sinh(t))+C\\ &=\sqrt2\arctan\left(\frac{\sqrt{\tan(x)}-\sqrt{\cot(x)}}{\sqrt2}\right)+C \end{align} $$
Solution 3:
Substitute $\tan x= t^2$ $$\int \sqrt{\tan x}+\sqrt{\cot x} dx=2\int\dfrac{t^2+1}{t^4+1}dt=2\int\dfrac{1+\frac{1}{t^2}}{(t-\frac1{t})^2+2} dt$$ Now make a $t-\frac{1}{t}$ substitution and we get the answer.
Solution 4:
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.