Integrate $\int{\frac{1}{x^2-x+1}dx}$ Original question was to integrate $$\int{\frac{(x+1)}{x^2-x+1}dx}$$ 
But I was able to break it into 2 parts: $$\frac{1}{2}\int{\frac{2x-1}{x^2-x+1}dx}+\frac{3}{2}\int{\frac{1}{x^2-x+1}dx} $$ 
The first part $\frac{1}{2}\int{\frac{2x-1}{x^2-x+1}dx}$ could be easily integrated by substituting $u={x^2-x+1}$ and thus, getting $\frac{\ln(x^2-x+1)}{2}$ as the answer. But I have no idea on how to integrate part 2 of the equation.
Any help will be appreciated.
 A: Hint : $x^2-x+1=\left(x-\frac{1}{2}\right)^2+\frac{3}{4}$.
A: I hope this explains why you need to make a perfect square.
Starting with your original problem ....
$$\begin{align}
\int{\frac{x+1}{x^2-x+1}dx} &= \int{\frac{x+1}{x^2-\frac{1}{2}x-\frac{1}{2}x+1}dx}\\
&= \int{\frac{x+1}{x^2-\frac{1}{2}x-\frac{1}{2}x+\frac{1}{4} + \frac{3}{4}}dx}\\
&= \int{\frac{x+1}{x(x-\frac{1}{2})-\frac{1}{2}(x-\frac{1}{2}) + \frac{3}{4}}dx}\\
&= \int{\frac{x+1}{(x-\frac{1}{2})^2 + \frac{3}{4}}dx}\\
&= \int{\frac{x+1}{\frac{3}{4}\cdot \frac{4}{3}(x-\frac{1}{2})^2 + \frac{3}{4}}dx}\\
&= \frac{1}{\frac{3}{4}}\int{\frac{x+1}{\frac{4}{3}(x-\frac{1}{2})^2 + 1}dx}\\
&= \frac{1}{\frac{3}{4}}\cdot\frac{\frac{4}{3}}{\frac{4}{3}}\int{\frac{x+1}{\frac{2^2}{\sqrt{3}^2}(x-\frac{1}{2})^2 + 1}dx}\\
&= \frac{4}{3}\int{\frac{x+1}{\bigg(\frac{2}{\sqrt{3}}(x-\frac{1}{2})\bigg)^2 + 1}dx}\\
&= \bigg(\frac{2}{\sqrt{3}}\bigg)^2\int{\frac{x-\frac{1}{2}+\frac{1}{2}+1}{\bigg(\frac{2}{\sqrt{3}}(x-\frac{1}{2})\bigg)^2 + 1}dx}\\
&= \frac{\bigg(\frac{2}{\sqrt{3}}\bigg)^2}{\color{red}{\frac{2}{\sqrt{3}}}}\int{\frac{\color{red}{\frac{2}{\sqrt{3}}}(x-\frac{1}{2}+\frac{3}{2})}{\bigg(\frac{2}{\sqrt{3}}(x-\frac{1}{2})\bigg)^2 + 1}dx}\\
&= \frac{2}{\sqrt{3}}\int{\frac{\color{green}{\frac{2}{\sqrt{3}}(x-\frac{1}{2})}+\sqrt{3}}{\bigg(\color{green}{\frac{2}{\sqrt{3}}(x-\frac{1}{2})}\bigg)^2 + 1}dx}\\
\end{align}$$ 
Now, just make the substitution $\displaystyle u = \frac{2}{\sqrt{3}}(x-\frac{1}{2})$
A: Here is a shorter path, using your own idea to start:
$$\int \frac{x+1}{x^2-x+1}dx = \dfrac{1}{2}\int \frac{(2x - 1) + 3}{x^2-x+1}dx$$
$$= \dfrac{1}{2}\int \frac{2x - 1}{x^2-x+1}dx + \dfrac{3}{2}\int \frac{1}{(x-\frac 1 2)^2 +(\frac{\sqrt{3}}{2})^2 }dx$$
$$= \frac{1}{2}\ln|x^2-x+1| + \frac{3}{2}\cdot \dfrac{2}{\sqrt{3}}\tan^{-1}\left(\dfrac{x-\frac{1}{2}}{\sqrt{3}/2}\right) +C$$ 
