Find $\int \frac{x^2 - x}{x^2 +x + 1}dx$ I know the answer is $x - \ln|x^2 + x + 1|$ but I don't understand how to get it. Its in the partial fraction decomposition section of homework. The way the homework worked it is like this...
$$
\int \frac{2x+1}{x^2 + x + 1} \, dx
$$
I see they split it up and got the derivative of $x^2 + x + 1$ in the numerator, but I don't understand how they did that or where the other interal dx came from.

Suppose you have
$$
\frac{\text{some polynomial}}{x^2 + x + 1}.
$$
Do long division and get
$$
\text{some polynomial} + \frac{\text{some first-degree polynomial}}{x^2+x+1}.
$$
In this case you get
$$
1 + \frac{-2x-1}{x^2+x+1}.
$$
First degree is the derivative of second degree, so $\dfrac{d}{dx}(x^2+x+1) = 2x+1$.  So
\begin{align}
u & = x^2 + x + 1, \\[6pt]
du & = (2x+1)\,dx.
\end{align}
Then we have
$$
\int \left(1 - \frac 1 u \right) du. 
$$
Somewhat more typically, one might have something like
$$
\frac{3x+5}{x^2+x+1}.
$$
Then one would write
$$
3x+5 = \frac 3 2 \left(2x + \frac{10}3\right)= \frac 3 2 \left((2x+1) + \frac 7 3\right)
$$
so we get
$$
\int\frac{3x+5}{x^2+x+1} \,dx=\frac 3 2 \int \frac{du}{u} + \frac 7 2 \int \frac{dx}{x^2+x+1}.
$$
That last integral would then need to get done by a different method, whose first step is completing the square.
