Integral of $\int \frac{\cos \left(x\right)}{\sin ^2\left(x\right)+\sin \left(x\right)}dx$ What is the integral of $\int \frac{\cos \left(x\right)}{\sin ^2\left(x\right)+\sin \left(x\right)}dx$ ?
I understand one can substitute $u=\tan \left(\frac{x}{2}\right)$
and one can get (1) $\int \frac{\frac{1-u^2}{1+u^2}}{\left(\frac{2u}{1+u^2}\right)^2+\frac{2u}{1+u^2}}\frac{2}{1+u^2}du$
but somehow this simplifies to (2) $\int \frac{1}{u}-\frac{2}{u+1}du$
to get: (3) $\ln \left(\tan \left(\frac{x}{2}\right)\right)-2\ln \left(\tan \left(\frac{x}{2}\right)+1\right)+C$
as the final answer. But how does one simplify (1) to (2)?

Consider the integral
\begin{align}
I = \int \frac{\cos(x) \, dx}{\sin^{2}(x) + \sin(x) } .
\end{align}
Method 1

Make the substitution $u = \tan\left(\frac{x}{2}\right)$ for which 
\begin{align}
\cos(x) &= \frac{1-u^{2}}{1+u^{2}} \\
\sin(x) &= \frac{2u}{1+u^{2}} \\
dx &= \frac{2 \, du}{1+u^{2}}
\end{align}
and the integral becomes
\begin{align}
I &= \int \frac{ \frac{1-u^{2}}{1+u^{2}} \cdot \frac{2 \, du}{1+u^{2}} }{ \left( \frac{2u}{1+u^{2}} \right)^{2} + \frac{2u}{1+u^{2}} } \\
&= \int \frac{2(1-u^{2})}{(1+u^{2})^{2}} \frac{ (1+u^{2})^{2} }{2u} \, \frac{du}{2u+ 1 + u^{2} } \\
&= \int \frac{(1-u^{2})^{2} \, du}{ u (1+u)^{2} } = \int \frac{(1-u) \, du}{u(1+u)} \\
&= \int \left( \frac{1}{u} - \frac{2}{1+u} \right) \, du\\
&= \ln(u) - 2 \ln(1+u) + c_{1}. 
\end{align}
This leads to 
\begin{align}
\int \frac{\cos(x) \, dx}{\sin^{2}(x) + \sin(x) } = \ln \left( \frac{\tan\left(\frac{x}{2}\right)}{ \left( 1 + \tan\left(\frac{x}{2}\right) \right)^{2} } \right) + c_{1} 
\end{align}
Method 2

Make the substitution $u = \sin(x)$ to obtain
\begin{align}
I &= \int \frac{du}{u^{2} + u} = \int \left( \frac{1}{u} - \frac{1}{1+u} \right) \, du \\
&= \ln(u) - \ln(1+u) + c_{2}
\end{align}
for which 
\begin{align}
\int \frac{\cos(x) \, dx}{\sin^{2}(x) + \sin(x) } = \ln\left( \frac{\sin(x)}{1+\sin(x) } \right) + c_{2}
\end{align}
