# Integrating $\sqrt{\tan x}$

I attempted to evaluate $$\int\sqrt{\tan(x)} dx$$ but, according to wolfram, I must've made a mistake somewhere. I couldn't find it myself so could you tell me where I messed up ? $$\int \sqrt{\tan(x)}dx$$ $$u=\sqrt{\tan(x)}\qquad du = \frac{\sec^2(x)}{2\sqrt{\tan(x)}}dx$$ $$du = \frac{u^4+1}{2u}dx\qquad dx = \frac{2u}{u^4+1}du$$ $$4\int \frac{u^2}{u^4+1}du$$ $$\frac{u^2}{u^4+1} = \frac{\frac{1}{2\sqrt{2}}u}{u^2-\sqrt{2}u+1}-\frac{\frac{1}{2\sqrt{2}}u}{u^2+\sqrt{2}u+1}$$ $$\frac{1}{2\sqrt{2}}\int\left(\frac{u}{u^2-\sqrt{2}u+1}-\frac{u}{u^2+\sqrt{2}u+1}\right)du$$ $$\frac{1}{2\sqrt{2}}\int\left(\frac{u}{u^2-\sqrt{2}u+\frac{1}{2}+\frac{1}{2}}-\frac{u}{u^2+\sqrt{2}u+\frac{1}{2}+\frac{1}{2}}\right)du$$ $$\frac{1}{2\sqrt{2}}\int\left(\frac{u_1}{\left(u_1-\frac{\sqrt{2}}{2}\right)^2+\frac{1}{2}}\right)du_1-\frac{1}{2\sqrt{2}}\int\left(\frac{u_2}{\left(u_2+\frac{\sqrt{2}}{2}\right)^2+\frac{1}{2}}\right)du_2$$ $$u_1-\frac{\sqrt{2}}{2} = \frac{1}{\sqrt{2}}\tan(\theta_1)\qquad du_1 = \frac{1}{\sqrt{2}}\sec^2(\theta_1)d\theta_1$$ $$u_2+\frac{\sqrt{2}}{2} = \frac{1}{\sqrt{2}}\tan(\theta_2)\qquad du_2 = \frac{1}{\sqrt{2}}\sec^2(\theta_2)d\theta_2$$ $$\frac{1}{2\sqrt{2}}\int\left(\frac{\frac{\sqrt{2}}{2} + \frac{1}{\sqrt{2}}\tan(\theta_1)}{\frac{1}{2}(1+\tan^2(\theta_1))}\right)\frac{1}{\sqrt{2}}\sec^2(\theta_1)d\theta_1-\frac{1}{2\sqrt{2}}\int\left(\frac{\frac{-\sqrt{2}}{2}+\frac{1}{\sqrt{2}}\tan(\theta_2)}{\frac{1}{2}(1+\tan^2(\theta_2))}\right)\frac{1}{\sqrt{2}}\sec^2(\theta_2)d\theta_2$$ $$\frac{1}{4}\int\left(\frac{\frac{\sqrt{2}}{2} + \frac{1}{\sqrt{2}}\tan(\theta_1)}{\frac{1}{2}\sec^2(\theta_1)}\right)\sec^2(\theta_1)d\theta_1-\frac{1}{4}\int\left(\frac{\frac{-\sqrt{2}}{2}+\frac{1}{\sqrt{2}}\tan(\theta_2)}{\frac{1}{2}\sec^2(\theta_2)}\right)\sec^2(\theta_2)d\theta_2$$ $$\frac{1}{2}\int\left(\frac{\sqrt{2}}{2} + \frac{1}{\sqrt{2}}\tan(\theta_1)\right)d\theta_1-\frac{1}{2}\int\left(\frac{-\sqrt{2}}{2}+\frac{1}{\sqrt{2}}\tan(\theta_2)\right)d\theta_2$$ $$\frac{1}{2}\left(\frac{\sqrt{2}}{2}\theta_1 + \frac{1}{\sqrt{2}}\ln|\sec(\theta_1)|\right)-\frac{1}{2}\left(-\frac{\sqrt{2}}{2}\theta_2 + \frac{1}{\sqrt{2}}\ln|\sec(\theta_2)|\right)$$ $$\frac{1}{2}\left(\frac{\sqrt{2}}{2}\tan^{-1}(u\sqrt{2}-1) + \frac{1}{\sqrt{2}}\ln|(u\sqrt{2}-1)^2+1|\right)-\frac{1}{2}\left(-\frac{\sqrt{2}}{2}\tan^{-1}(u\sqrt{2}+1) + \frac{1}{\sqrt{2}}\ln|(u\sqrt{2}+1)^2+1|\right)$$ The above is one whole line. $$\frac{1}{2}\left[\frac{\sqrt{2}}{2}\tan^{-1}\left(\frac{u\sqrt{2}}{2-2u^2}\right)+\frac{1}{\sqrt{2}}\ln\left|\frac{(u\sqrt{2}-1)^2+1}{(u\sqrt{2}+1)^2+1}\right|\right]$$ Here I used the identity $$\arctan(x) + \arctan(y) = \left(\frac{x+y}{1-xy}\right)$$

$$\frac{\sqrt{2}}{4}\tan^{-1}\left(\frac{u\sqrt{2}}{2-2u^2}\right)+\frac{1}{2\sqrt{2}}\ln\left|\frac{(u\sqrt{2}-1)^2+1}{(u\sqrt{2}+1)^2+1}\right|$$ $$\frac{\sqrt{2}}{4}\tan^{-1}\left(\frac{\sqrt{2\tan(x)}}{2-2\tan(x)}\right)+\frac{1}{2\sqrt{2}}\ln\left|\frac{\tan(x)-\sqrt{2\tan(x)}+1}{\tan(x)+\sqrt{2\tan(x)}+1}\right|$$

Same start, $u=\sqrt{\tan x}$, so formally $x=\arctan(u^2)$, $dx=\frac{2u\; du}{1+u^4}$, \begin{align} \int\sqrt{\tan x}\; dx &\equiv \int\frac{2u^2}{u^4+1}\; du \\\\ &= \int\frac{u^2+1}{u^4+1}\; du + \int\frac{u^2-1}{u^4+1}\; du \\\\ &= \int\frac{(u^2+1)/u^2}{(u^4+1)/u^2}\; du + \int\frac{(u^2-1)/u^2}{(u^4+1)/u^2}\; du \\\\ &= \int\frac{d\left(u-\frac 1u\right)}{\left(u-\frac 1u\right)^2+2} + \int\frac{d\left(u+\frac 1u\right)}{\left(u+\frac 1u\right)^2-2} \\\\ &= \frac 1{\sqrt 2}\arctan\left(\frac 1{\sqrt 2}\left(u-\frac 1u\right)\right) + \frac 1{2\sqrt 2}\ln\left| \frac {\left(u+\frac 1u\right)-\sqrt 2} {\left(u+\frac 1u\right)+\sqrt 2} \right| +\text{local constant} \ . \end{align} (The coefficient in the logarithmic term is fine. For the term involving $\arctan$, we can pass to its "inverse argument". I hope, this is an answer giving the profit in the future, not only the chasing of $\pm1/2$ in this particular case.)
• Why is there a $d$ in the 4th line ? – Adam Apr 19 '18 at 20:21
• $df(u)$ stays for $f'(u)\; du$, where $f$ is a suitable function. Sorry, i corrected now a second $du$ which survied the copy+paste action. In such a situation, the substitution $y=f(u)$ is imminent. In our case we substitute $\displaystyle y=u\mp\frac 1u$ in the one, respectively other integral, and the integrals of $dy/(y^2\pm 2)$ are in the tables. – dan_fulea Apr 21 '18 at 22:22