TITLE: Is it possible to integrate $\int \frac{\mathrm{d}x}{\sin^2 x+\sin x+1}$ without involving complex numbers?
QUESTION [2 upvotes]: The integral is $$\int \frac{\mathrm{d}x}{\sin^2 x+\sin x+1}$$

Consider
$$\int \frac{\mathrm{d}x}{ax^2+bx+c}$$
There are a total of three cases, depending on the discriminant of $ax^2+bx+c$. Two of which are shown here (#1).
The third one, i.e. when $\Delta=0$, simply means evaluating $$\frac{1}{a}\int \frac{\mathrm{d}x}{\big(x+\frac{b}{2a}\big)^2} $$
For the first two cases, you can see different substitutions are used so as to prevent $i$ from appearing in the answer, hence resulting in an $\arctan$ function and a $\ln$ function respectively. The discrepancy arises when we change $+(4ac-b^2)$ to $-(b^2-4ac)$.

In general, is it possible to evaluate
$$\int \frac{\mathrm{d}x}{a\sin^2 x+b\sin x+c}$$ such that the result does not contain complex numbers when $\Delta_{\sin x}<0$?
The only approach I can think of when $\Delta_{\sin x}>0$ is by partial fraction decomposition, which differs from the method of substitution used above.

REPLY [1 votes]: The half-angle substitution $\tan\frac x2=\frac{1-t}{1+t}$ allows the integral to be expressed  as
\begin{align}
&I=\int \frac{1}{\sin^2 x+\sin x+1}dx
= 2\int\frac{1+{t^2}}{3+t^4}dt
\end{align}
which can be readily integrated to yield
$$I= \frac{\sqrt3+1}{\sqrt{6\sqrt3}}\tan^{-1}\frac{t-\frac{\sqrt3}t}{\sqrt{2\sqrt3}}
-\frac{\sqrt3-1}{\sqrt{6\sqrt3}}\coth^{-1}\frac{t+\frac{\sqrt3}t}{\sqrt{2\sqrt3}}+C
$$
{"set_name": "stack_exchange", "score": 2, "question_id": 2120557}