<s>[INST] Help with integrating $\int \frac{dx}{1+\sqrt{\tan(x)}}$ Starting off with subbing $u^2 = \tan(x)$ to remove the square root, I got:

*

*$$\int \frac{2u}{(1+u)(1+u^4)} du$$ (Deriving that $\sec^2(x) = 1+u^4$)

Then by applying the partial fractions method, I get:


*$$\int \frac{-1}{1+u} du + \int \frac{u^3-u^2+u+1}{1+u^4} du$$
The first integral is manageable but for the second one I had to split the individual terms in the numerator into their own fractions to further obtain:


*$$\int \frac{u^3}{1+u^4}du +\int \frac{u}{1+u^4}du + \int \frac{1-u^2}{1+u^4}du $$
Now, the first two I could solve however it is the last one that I am unable to move forward with;
$$ \int \frac{1-u^2}{1+u^4}du $$
 [/INST] Here there is slightly  alternative way using a bit of brute force, pushing the decomposition into partial fractions. We can prepare the way for partial fractions by trying to factor the denominator in difference of squares; we can force this like
\begin{align*}1+u^4&=u^4+2u^2-2u^2+1\\
&=(u^4+2u^2+1)-(2u^2)\\
&=(u^2+1)^2-(\sqrt{2}u)^2\\
&=(u^2+1+\sqrt{2}u)(u^2+1-\sqrt{2}u)\\
&=(u^2+\sqrt{2}u+1)(u^2-\sqrt{2}u+1)
\end{align*}
Then we can use partial fraction in order to write
\begin{align*}\frac{1-u^2}{1+u^4}&=\frac{Au+B}{u^2+\sqrt{2}u+1}+\frac{Cu+D}{u^2-\sqrt{2}u+1}\\
&=\frac{\frac{1}{2\sqrt{2}}(2u+\sqrt{2})}{u^2+\sqrt{2}u+1}+\frac{-\frac{1}{2\sqrt{2}}(2u-\sqrt{2})}{u^2-\sqrt{2}u+1}.
\end{align*}
Substitution in each denominator reduce calculus to know $\int \frac{1}{t}dt=\ln|t|+K$. Substitution back give the answer
$$\frac{1}{2\sqrt{2}}\ln \left|\frac{u^2+\sqrt{2}u+1}{u^2-\sqrt{2}u+1} \right|+K$$
</s>