# Trig substitution fails for evaluating $\int \frac{\cos x \sin x}{\sin^2{x} + \sin x + 1} dx$?

Evaluate the integral $$\int \frac{\cos x \sin x}{\sin^2{x} + \sin x + 1} dx$$ Basically I could substitute: $t = \sin x$ and get:

$$\int \frac{t}{t^2 +t + 1} dt$$

But, although it seems a reasonable integral to solve, it doesn't.

So I tried to utilize some trigonometric identities but it didn't work out so well.

• Do what you did. Complete the square in the denominator. (You have a typo in the first display.) – David Mitra Jan 30 '15 at 11:29
• Thank you @DavidMitra. "Complete the square", how could I have miss that? – Elimination Jan 30 '15 at 11:38
• You're welcome. (After completing the square, the integral might still seem strange. But just let $w=t+1/2$, the numerator will then be $w-1/2$. Split the integral in two.) – David Mitra Jan 30 '15 at 11:42
• I left with evaluating $\int \frac{w}{w^2+3/4}$ and $\int \frac{1}{w^2 + 3/4}$. I know the function $\arctan(x)$ has something to do with this integral since $\frac{d}{dx} \arctan(x) = \frac{1}{x^2 + 1}$, but not sure how to utilize it. – Elimination Jan 30 '15 at 12:05
• Factor $3/4$ out from the denominator. It becomes ${3\over4}\bigl( [(2/\sqrt3)w]^2+1\bigr)$ – David Mitra Jan 30 '15 at 12:07

As $\dfrac{d(t^2+t+1)}{dt}=2t+1$

$$2I=\int\frac{2t}{t^2+t+1}dt=\int\frac{2t+1}{t^2+t+1}dt-\int\frac1{\left(t+1/2\right)^2+(\sqrt3/2)^2}dt$$

Now, $$\int\frac{2t+1}{t^2+t+1}dt=\ln|t^2+t+1|+C$$

and set $t+a=b\tan\theta$ to find $$\int\frac{dt}{\left(t+a\right)^2+b^2}=\frac1{2a}\arctan\dfrac{t+a}b+K$$

$$\int \frac{t}{t^2 +t + 1} dt = \int \frac{t}{\left(t+\frac 12\right)^2 + \frac 34}\,dt$$

$$\frac 34 = \left(\frac{\sqrt 3}2\right)^2$$

So , in therms of substitution, $$t+\frac 12 = \frac {\sqrt 3}2 \tan\theta\implies dt = \frac {\sqrt 3}2 \sec^2\theta\,d\theta,\quad \text{and}\;t = \frac{\sqrt 3}2\tan\theta - \frac 12$$

We can also express $\theta$ as a function of $t$: $$\tan\theta = \frac 2{\sqrt 3}\left(t+\frac 12\right) \implies \theta = \arctan\left(\frac 2{\sqrt 3}\left(t+\frac 12\right)\right)$$

\begin{align}\int \frac{t}{\left(t+\frac 12\right)^2 + \frac 34}\,dt &= \int \frac{\left(\frac{\sqrt 3}2\tan\theta - \frac 12\right)\cdot \frac{\sqrt 3}2 \sec^2\theta}{\frac 34(\tan^2 \theta + 1)}\\ \\ & =\int \frac{\left(\frac 34\right)\tan\theta\sec^2\theta - \frac{\sqrt 3}4\sec^2\theta\,d\theta}{\frac 34(\tan^2\theta + 1)}\\ \\ &= \int \frac{\tan\theta\sec^2\theta}{\sec^2 \theta}\,d\theta -\frac 1{\sqrt 3}\int \frac{\sec^2\theta\,d\theta}{\sec^2 \theta} \\ \\ &= \int \frac {\sin\theta}{\cos\theta}\,d\theta - \frac 1{\sqrt 3}\int \,d\theta \end{align}

Now all that remains is readily evaluating the integrals, then back-substituting in terms of $t$, then again for the substitution $t = \sin\theta$.