Evaluate the following integral : $$
\int \frac{\cot x d x}{(1-\sin x)(\sec x+1)}
$$ I have tried to solve the problem by converting all trig functions into $sin$ and $cos$ form, but I am stuck at the following step, how do I integrate this integral : $$
\int \frac{(1+\sin x) d x}{\sin x(1+\cos x)}
$$ please help
 A: Write as $$\int\dfrac1{\sin x(1+\cos x)}dx+\int\dfrac1{1+\cos x}dx$$
Use $$\cos2y=2\cos^2y-1$$ and $$\sin2y=2\sin y\cos y$$
and divide the numerator and the denominator of the first integral by $\cos^4\dfrac x2$ and set $\tan\dfrac x2=u$
A: Multiply the numerator and denominator by $1-\cos{x}$:
$$I=\int \frac{1-\cos{x}+\sin{x}-\cos{x}\sin{x}}{\sin^3{x}} \; dx$$
Split this into four integrals:
$$I=\int \csc^3{x} \; dx -\int \csc^2{x}\cot{x} \; dx +\int \csc^2{x} \; dx -\int \cot{x}\csc{x} \; dx$$
$$I=\frac{-\cot{x}\csc{x}-\ln{\big | \cot{x} + \csc{x} \big |}}{2} + \frac{\cot^2{x}}{2}- \cot{x} + \csc{x} +C$$
A: Now, $$\frac{1+\sin{x}}{\sin{x}(1+\cos{x})}=\frac{\sin{x}}{\sin^2x(1+\cos{x})}+\frac{1}{1+\cos{x}}=$$
$$=\frac{\sin{x}}{(1-\cos^2x)(1+\cos{x})}+\frac{1}{2\cos^2\frac{x}{2}}.$$
Can you end it now?
A: Why not to use the tangent half-angle substitution $x=2 \tan ^{-1}(t)$ which gives
$$\int \frac{\cot (x)}{(1-\sin (x)) (\sec (x)+1)}\,dx=\int \frac{(t+1)^2}{2 t}\,dt=\int \left(\frac{t}{2}+\frac{1}{2 t}+1 \right)\,dt$$
