<s>[INST] this integral $\int\frac{2-\sin{x}}{\sin^2{x}-\sin{x}+1}dx$ Find integral
$$\int\dfrac{2-\sin{x}}{\sin^2{x}-\sin{x}+1}dx$$
As suggested ,we take the Weierstrass Substitution is often useful in integrals such as the original.
$$
\begin{align}
\sin(x)&=\frac{2z}{1+z^2}\\
\cos(x)&=\frac{1-z^2}{1+z^2}\\
\mathrm{d}x&=\frac{2\,\mathrm{d}z}{1+z^2}
\end{align}
$$
I known is equal to
$$\int\dfrac{4(z^2-z+1)}{z^4-2z^3+6z^2-2z+1}dz$$
but I don't know how I should calculate the last integral.
 [/INST] Hint
Note
$$\dfrac{2-\sin{x}}{\sin^2{x}-\sin{x}+1}=\dfrac{1}{w_{1}-w_{2}}\left(\dfrac{2-\sin{x}}{\sin{x}-w_{1}}-\dfrac{2-\sin{x}}{\sin{x}-w_{2}}\right)$$
where $w_{1},w_{2}$ are equation $x^2-x+1=0$complex roots
and
$$\dfrac{2-\sin{x}}{\sin{x}-w_{1}}=-1+\dfrac{2-w_{1}}{\sin{x}-w_{1}}$$
$$\dfrac{2-\sin{x}}{\sin{x}-w_{2}}=-1+\dfrac{2-w_{2}}{\sin{x}-w_{2}}$$
use this following
$$\int\dfrac{1}{\sin{x}-A}dx=\dfrac{2\arctan{\left(\dfrac{1-A\tan{\frac{x}{2}}}{\sqrt{A^2-1}}\right)}}{\sqrt{A^2-1}}$$
then you can solve it
</s>