<s>[INST] Solving $\int\frac{dx}{1+\tan x}$ How do we solve $$\int\frac{dx}{1+\tan x}$$? I found two ways to solve it, one with the Weierstrass substitution ($t=\tan(\dfrac x2)$) and one with simply substituting $u=\tan x$ (which is better in my opinion). To solve it with the Weierstrass substitution, we get $$\int\dfrac{\frac{2}{1+t^2}}{1+\dfrac{2t}{1-t^2}}dt$$ Which is very complicated. But if we do $u=\tan x$ we would need to solve $$\int\frac{1}{(u+1)\left(u^2+1\right)}du$$Which is easier. Are there any other ways to solve this problem?
 [/INST] Solution using Euler substitution, provided $\cos(x)>0$:
$$\begin{align*}
& \int \frac{dx}{1+\tan(x)} \\
&= \int \frac{\cos(x)}{\sin(x)+\cos(x)} \, dx \\
&= \int \frac{du}{u+\sqrt{1-u^2}} & u=\sin(x) \\
&= -2 \int \frac{1-t^2}{(1+t^2) \left(1-2t -t^2\right)}\,dt & u=-\frac{2t}{1+t^2}\\
&= \int \left(\frac{-1-t}{1-2t-t^2} - \frac{1}{1+t^2} - \frac t{1+t^2}\right) \, dt \\
&= \frac12 \ln\left|1-2t-t^2\right| - \arctan(t) - \frac12 \ln\left(1+t^2\right) + C \\
&= \frac12 \ln\left|\frac{(1-u)\left(1-\sqrt{1-u^2}\right)-u^2}{1-\sqrt{1-u^2}}\right| - \arctan\left(\frac{\sqrt{1-u^2}-1}u\right) + C \\
&= \frac12 \ln\left|\cos(x)+\sin(x)\right| + \arctan\left(\frac{1-\cos(x)}{\sin(x)}\right) + C \\
\end{align*}$$
and we recall
$$\arctan\left(\frac{1-\sqrt{1-z^2}}z\right) = \arctan\left(\frac{z}{1+\sqrt{1-z^2}}\right) = \frac12 \arcsin(z)$$
</s>