Evaluation of $\int \frac{1-\sin x}{(1+\sin x)\cos x}dx$ Evaluate $$I=\int \frac{(1-\sin x) dx}{(1+\sin x)\cos x}$$
I tried in the following way:
$$1-\sin x=1-\cos\left(\frac{\pi}{2}-x\right)=2 \sin^2\left(\frac{\pi}{4}-\frac{x}{2}\right)$$ 
Similarly $$1+\sin x=2 \cos^2\left(\frac{\pi}{4}-\frac{x}{2}\right)$$ 
So
$$I=\int \tan^2\left(\frac{\pi}{4}-\frac{x}{2}\right) \sec x \: dx=\int \sec^2\left(\frac{\pi}{4}-\frac{x}{2}\right) \sec x \: dx-\int \sec x \:dx$$ 
If $$J=\int \sec^2\left(\frac{\pi}{4}-\frac{x}{2}\right) \sec x \: dx$$ Applying parts for $J$ we get
$$J=-2\sec x \tan\left(\frac{\pi}{4}-\frac{x}{2}\right)+2\int \sec x \tan x \tan\left(\frac{\pi}{4}-\frac{x}{2}\right)dx  $$
But i am clueless from here
 A: One may write
$$
\begin{align}
I&=\int \frac{(1-\sin x) dx}{(1+\sin x)\cos x}
\\\\&=\int \frac{(1-\sin x)\cos x dx}{(1+\sin x)\cos^2 x}
\\\\&=\int \frac{(1-\sin x)\cos x dx}{(1+\sin x)(1-\sin^2 x)}
\\\\&=\int \frac{(1-u)du}{(1+u)(1-u^2)}\quad (u=\sin x)
\\\\&=\int \frac{du}{(1+u)^2}
\\\\&=-\frac{1}{1+\sin x}+C.
\end{align}
$$ 
Edit. (from @Bernard) The Bioche rules  are rules that give hints on the useful substitutions for the integration of rational functions in $\sin$ and $\cos$. Namely you consider the differential form $f(\sin x,\cos x)dx$, and substitute successively $−x$ to $x$, then $π−x$, and finally $π+x$. If the differential form is invariant by one of these substitutions, set $u$ equal to the function which is invariant by the same substitution – which is $u=\cos x$, $u=\sin x$ or $u=\tan x$, respectively.
If it happens the differential form is invariant by two of these substitutions, one may set $u$ equal to a trigonometric function of $2x$.
The worst case is when none of these substitutions work. As a last resort, one sets $u=\tan \frac x2$, since there are standard formulae which express $\sin x,\cos x$ and $\tan x$ as functions of $u$.
A: Multiply both numerator and denominator by $\;1+\sin x\;$ , so you get ( observe that $\;\cos x=(1+\sin x)'\;$):
$$\int\frac{\cos x}{(1+\sin x)^2}dx=-\frac1{1+\sin x}+K$$
