Answer
$$x+\ln |x|-3 \ln |x+1|+C$$
Work Step by Step
Given $$\int \frac{\left(x^{2}-x+1\right) d x}{x^{2}+x}$$
By using long division, we get:
\begin{aligned}
\frac{x^{2}-x+1}{x^{2}+x}&=1+\frac{-2 x+1}{x^{2}+x}\\
&=1+\frac{-2 x+1}{x(x+1)}
\end{aligned}
Then
\begin{align*}
\frac{-2 x+1}{x(x+1)}&=\frac{A}{x}+\frac{B}{x+1}\\
&=\frac{A(x+1)+B x}{x(x+1)}\\
-2x+1&=A(x+1)+B x
\end{align*}
\begin{align*}
\text{at } x&=0 \ \ \ \ \to A=1 \\
\text{at } x&= -1\ \ \ \ \to B=-3
\end{align*}
Hence
\begin{aligned}
\int \frac{x^{2}-x+1}{x^{2}+x} d x &=\int 1 \, d x+\int \frac{1}{x} d x-\int \frac{3}{x+1} d x \\
&=x+\ln |x|-3 \ln |x+1|+C
\end{aligned}