TITLE: How do I solve the integral: $\int \frac{\sin x}{\tan^2x+\cos^2x}\,dx$
QUESTION [5 upvotes]: As the title says, I want to know how to solve this integral: $$\int \frac{\sin x}{\tan^2x+\cos^2x}\,dx.$$ I tried to write everything as $\cos x$ and I got that the integral is equal to: $$ \int \frac{\sin x\cos^2x}{\cos^4x-\cos^2x+1}\,dx.$$ I tried to substitute $\cos x=t \implies -\sin x \,dx=dt$ and I got the integral: $$-\int \dfrac{t^2}{t^4-t^2+1}\,dt,$$ which I do not know how to solve. Is everything I have done so far right or I can do it in another way that is faster or easier?

REPLY [5 votes]: You did well. For the rest, use the decomposition:
\begin{align}
t^4-t^2+1 & =  t^4+2t^2+1-3t^2 \\ 
& =  (t^2+1)^2-3t^2 \\
& =  (t^2+\sqrt{3}t+1)(t^2-\sqrt{3}t+1).
\end{align}