I've been trying to solve this integral
$$\int \frac{1}{\sin^2(x)+\sin(x)+1} dx$$
First, use the Half-Angle Tangent/Weierstrass Substitution:
$$2\int \frac{1+t^2}{t^4+2t^3+6t^2+2t+1} dt$$
Factor the denominator:
$$2\int \frac{1+t^2}{(t^2+(1+\sqrt3i)t+1)(t^2+(1-\sqrt3i)t+1)} dt$$
Use Partial Fractions and split the integral:
$$\frac{i}{3}\int \frac{1}{t^2+(1+\sqrt3i)t+1} dt - \frac{i}{3}\int \frac{1}{t^2+(1-\sqrt3i)t+1} dt$$
Complete the square:
$$\frac{i}{3}\int \frac{1}{(t+0.5(1+\sqrt3i))^2+\frac{-\sqrt3i+3}{2}} dt - \frac{i}{3}\int \frac{1}{(t+0.5(1-\sqrt3i))^2+\frac{\sqrt3i+3}{2}} dt$$
Use Trigonometric Substitution. Substituting everything back in, the final answer is:
Which is wrong. What went wrong? The derivative should give $$\frac{1}{\sin^2(x)+\sin(x)+1}$$