# 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)?

• Let $u=\sin x$, then easy partial fractions. Weierstrass substitution is overkill. – André Nicolas Oct 5 '14 at 23:36
• – Martin Sleziak Jun 1 '17 at 12:25

Hints; let $u=\sin x$ and complete the square on the new denominator; $u^2+u=(u+\frac12 )^2-\frac14$

It's all trivial substitutions and algebraic manipulations from here.

Weirstrass substitution is too much of a trouble here, I reccomend not going that way.

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}