<s>[INST] Evaluate the following integral I got stuck with the integral below. I have tried to make it look like the derivative of arctan.
$$\int \frac{2-x}{x^2-x+1}\,dx$$
Thank you!
 [/INST] $$\int \frac{2-x}{x^2-x+1}\ dx=\frac{1}{2}\int \frac{3-(2x-1)}{x^2-x+1}dx\\=\frac{1}{2}\int \frac{3}{x^2-x+1}\ dx-\frac 12\int \frac{
2x-1}{x^2-x+1}\ dx\\=\frac{3}{2}\int \frac{1}{\left(x-\frac 12\right)^2+\frac{3}{4}} dx-\frac 12\int \frac{x^2-x+1}{x^2-x+1}dx$$
Substitute $u:=x^2-x+1$ and $du=(2x-1)dx$
Substitute $\varphi:=x-\frac 1 2$ and $d\varphi=dx$
$$-\frac 1 2\int \frac 1 u du+\frac 3 2\int \frac {1} {\varphi ^2+3/4} d\varphi$$
From here it should be easy, in the end you should get $$\boxed{
\color{blue}{=\sqrt 3 \arctan\bigg(\frac{2x-1}{\sqrt 3}\bigg)-\frac 1 2 \ln|x^2-x+1|+C}}$$
</s>