Evaluate $\int\frac{\cot x}{\cos^2 x-\cos x+1}\,\,dx$ $$\int\frac{\cot x}{\cos^2 x-\cos x+1}\,\,dx$$
Please guide me by which term it should be substituted to get the result of this integration. I have tried it by using $\cos x =t$, but it went so long and more problematic.
 A: Hint
Starting from $$I=\int \frac{\cot (x)}{\cos ^2(x)-\cos (x)+1}dx$$ and using $\cos(x)=t$, $x=\cos^{-1}(t)$, $dx=-\frac{dt}{\sqrt{1-t^2}}$, $\cot(x)=\frac{t}{\sqrt{1-t^2}}$, you should arrive to $$I=-\int\frac{t}{\left(1-t^2\right) \left(t^2-t+1\right)}dt$$ and partial fraction decomposition leads to $$\frac{-t}{\left(1-t^2\right) \left(t^2-t+1\right)}=\frac{1-2 t}{3 \left(t^2-t+1\right)}+\frac{1}{2 (t-1)}+\frac{1}{6 (t+1)}$$
I am sure that you can take from here.
Added later
You could also use the tangent half-angle substitution (Weierstrass substitution) and so, using $y=\tan(\frac x2)$, arrive to $$I=\int \frac{1-y^4}{3 y^5+y}dy=\int \Big(\frac{1}{y}-\frac{4 y^3}{3 y^4+1}\Big)dy$$ which is even simpler than the previous one.
A: Hint :
\begin{align}
\int\frac{\cot x}{\cos^2 x-\cos x+1}\;\mathrm dx&=\int\frac{\frac{\cos x}{\sin x}}{\cos^2 x-\cos x+1}\cdot\frac{\sin^2 x}{\sin^2 x}\;\mathrm dx\\[10pt]
&=\int\frac{\cos x}{\cos^2 x-\cos x+1}\cdot\frac{\sin  x}{1-\cos^2 x}\;\mathrm dx\\[10pt]
&=\int\frac{y}{y^2 -y+1}\cdot\frac{\mathrm dy}{y^2 - 1}\qquad\Rightarrow\qquad\text{set}\;y=\cos x\\[10pt]
&=-\frac{1}{3}\underbrace{\int\frac{2y-1}{y^2 -y+1}\mathrm dy}_{\large\color{red}{\text{set}\;t\,=\,y^2 -y+1}}+\frac{1}{2}\underbrace{\int\frac{\mathrm dy}{y-1}}_{\large\color{red}{\text{set}\;u\,=\,y-1}}+\frac{1}{6}\underbrace{\int\frac{\mathrm dy}{y+1}}_{\large\color{red}{\text{set}\;v\,=\,y+1}}
\end{align}
