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 ?

$\displaystyle \frac{1-sinx}{1+sinx}=\frac{2}{1+sinx}-1=\frac{2}{(sin\frac{x}{2}+cos\frac{x}{2})^{2}}-1$
$\displaystyle =\frac{1}{cos^{2}(\frac{x}{2}-\frac{\pi}{4})}-1=tan^{2}(\frac{x}{2}-\frac{\pi}{4})$
$\displaystyle \theta=\frac{x}{2}-\frac{\pi}{4}\Rightarrow 2d\theta=dx$
$\displaystyle z=tan\theta\Rightarrow dz=(1+tan^{2}\theta)d\theta $
$\displaystyle dz-d\theta=tan^{2}\theta d\theta=d(z-\theta)$
$\displaystyle \int\frac{1-sinx}{1+sinx}dx=2\int tan^{2}\theta d\theta=2\int d(z-\theta)=2z-2\theta+c$
$\displaystyle \int\frac{1-sinx}{1+sinx}=2tan(\frac{x}{2}-\frac{\pi}{4})-2(\frac{x}{2}-\frac{\pi}{4})+c=2tan(\frac{x}{2}-\frac{\pi}{4})-x+C$
