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!
 A: You indeed let the linear term disappear from the denominator by a shift of the variable to perform completion of the square, $x-\frac12=t$:
$$\int \frac{2-x}{x^2-x+1}dx=\int \frac{\frac32-t}{t^2+\frac34}dt=\int \frac{\frac32}{t^2+\frac34}dt-\frac12\ln\left(t^2+\frac34\right).$$
After rescaling, you end-up with an $\arctan$.

You can even foresee how to perform the rescaling after the linear term is gone, and use $t=\sqrt{\frac43}(x-\frac12)$, $x=\sqrt{\frac34}t+\frac12$ up-front:
$$\int \frac{2-x}{x^2-x+1}dx=\sqrt{\frac34}\int\frac{\frac32-\sqrt{\frac34}t}{\frac34(t^2+1)}dt=\sqrt3\arctan(t)-\frac12\ln(t^2+1).$$
A: Note that $\int \frac{2-x}{x^2-x+1}=\int \frac{2}{x^2-x+1}-\int \frac{x}{x^2-x+1}$
Complete the square for the first term. This makes a very natural arctan substitution.
For the second term, rewrite the numerator as $x=\frac{1}{2}(2x-1+1)$
A: HINT: $$\int \frac{2-x}{x^2-x+1}\ dx=\frac{1}{2}\int \frac{3-(2x-1)}{x^2-x+1}$$
$$=\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{d(x^2-x+1)}{x^2-x+1}$$
A: $$\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}}$$
