How to integrate hyperbolic function $\frac{1-\sin(x)}{1+\sin(x)}$ I'm trying to find a primitive of $ \frac{1-\sin(x)}{1+\sin(x)} $. By changing the variable to $t=\tan(\frac{x}{2})$ and letting $\sin(x) = \frac{2t}{1+t^2}$ I get the following integral:
\begin{align}
& \int \frac{1-\sin(x)}{1+\sin(x)} \, dx \\[8pt] = {} & \int \frac{ 1-\frac{2t}{1+t^2} } { 1+ \frac{2t}{1+t^2} } \frac{2}{1+t^2} \, dt \\[8pt]
= {} & 2\int \frac{ t^2 -2t +1 }{ (t^2 +2t+1)(t^2 + 1) } \, dt \\[8pt]
= {} & 2\int \frac{t^2 -2t +1 }{(t+1)^2(t^2+1)} \, dt \end{align}
Now I know that I could do a partial fraction expansion. I would get 3 simpler fraction but I also know that the result contains only two fraction by calculating it in xcas: $$ \int \frac{1-\sin(x)}{1+\sin(x)} \, dx = 2\left(-\frac{2}{\tan(\frac{x}{2}) +1} - \frac{x}{2}\right) $$
Is there an easier way to calculate this primitive ?

$$\begin{align}\int\frac{1-\sin x}{1+\sin x}dx &= \int\left(\frac2{1+\sin x}-1\right)\,dx
\\&= \int\frac2{1+\frac{2t}{1+t^2}}\cdot\frac2{1+t^2}\,dt-x
\\&= \int\frac4{1+2t+t^2}\,dt-x
\\&= \int\frac4{(t+1)^2}\,d(t+1)-x
\\&= -\frac4{t+1}-x
\\&= -\frac4{\tan\frac x2+1}-x
\end{align}$$
