How to find the integral of a quotient of rational functions? How do I compute the following integral: $$\int \dfrac{x^4+1}{x^3+x^2}\,dx$$
My attempt:
We can write $$\dfrac{x^4+1}{x^3+x^2} = \dfrac{A}{x^2} + \dfrac{B}{x} + \dfrac{C}{x+1}$$
It is easy to find that
$A=1$,
$B=2$, and
$C=-1$.
Therefore 
$$\frac{x^4+1}{x^3+x^2} = \frac{1}{x^2} + \frac{2}{x} - \frac{1}{x+1}$$
Therefore: 
$$\int \frac{x^4+1}{x^3+x^2}\,dx = \int \frac{dx}{x^2} + \int \dfrac{2\,dx}{x} - \int \frac{dx}{x+1} = -\frac{1}{x} +2\log \vert x\vert - \log \vert x+1 \vert + C$$
The problem is I was supposed to find:  $$\int \frac{x^4+1}{x^3+x^2}\,dx = \frac{x^2}{2} - x - \frac{1}{2} - \log \vert x \vert + 2 \log \vert x+1 \vert + C$$
Where is my mistake?

To break a rational polymomial expression into parts, the degree of the numerator must be less than the degree of the denominator.
This is not the case with $\dfrac{x^4+1}{x^3+x^2}$.  Using long division, we find

\begin{array}{rcccccccc}
          &   &  x  &  -  &  1   &\\
          &   & --- & --- & ---  & --- & ---  & --- & ---\\
x^3 + x^2 & | & x^4 &  +  & 0x^3 & +   & 0x^2 &  +  & 1 \\
          &   & --- & --- & --- \\
          &   & x^4 &  +  & x^3\\
          &   & --- & --- & ---  & --- & ---  \\
          &   &     &     & -x^3 &  +  & 0x^2 \\
          &   &     &     & -x^3 &  -  &  x^2 \\
          &   &     &     & ---  & --- & ---  \\
          &   &     &     &      &     &  x^2 &  +  & 1.  \\
\end{array}

So $\dfrac{x^4+1}{x^3+x^2} = x - 1 + \dfrac{x^2 + 1}{x^3 + x^2}$.
And you need to solve
$\dfrac{x^2+1}{x^3+x^2} = \dfrac{A}{x^2} + \dfrac{B}{x} + \dfrac{C}{x+1}$
$x^2 + 1 = A(x+1) + Bx(x+1) + Cx^2$
Let $x = -1$ and you get
$C = 2$
Let $C = 2$ and you get
$x^2 + 1 = A(x+1) + Bx(x+1) + 2x^2$
$-x^2 + 1 = A(x+1) + Bx(x+1)$
$1-x = A + Bx$
$A = 1$ and $B = -1$.
So $\dfrac{x^4+1}{x^3+x^2} = x - 1 + \dfrac{1}{x^2} - \dfrac{1}{x} + \dfrac{2}{x+1}$.
etc
