<s>[INST] How to integrate when the degree of the numerator is higher than the denominator? I need to solve
$$\int\frac{x^5+4}{x^3+x^2}\,dx$$
I first tried to do a division, which gave me
$$\int\bigg[\frac{x^3}{x+1}+\frac{4}{x^2(x+1)}\bigg]\,dx$$
However, looking at the book, the integral is supposed to be transformed to
$$\int\bigg[x^2-x+1-\frac{4}{x}+\frac{4}{x^2}+\frac{3}{x+1}\bigg]\,dx$$
How am I suppose to end up with this integral ?
 [/INST] Polynomial factoring and partial fraction expansions help.
First, write
$$\frac{x^3}{x+1}=\frac{x^3+1-1}{x+1}$$
Then, factor the cubic polynomial $x^3+1$ to give
$$\frac{x^3}{x+1}=\frac{(x+1)(x^2-x+1)}{x+1}-\frac{1}{x+1}$$
$$=x^2-x+1-\frac{1}{x+1}$$
Next, use partial fraction expansion to write
$$\frac{1}{x(x+1)}=\frac{1}{x}-\frac{1}{x+1}$$
Thus, 
$$\frac{4}{x^2(x+1)}=\frac{4}{x}\left(\frac{1}{x}-\frac{1}{x+1}\right)$$
$$=\frac{4}{x^2}-4\left(\frac{1}{x(x+1)}\right)$$
$$=\frac{4}{x^2}-4\left(\frac{1}{x}-\frac{1}{x+1}\right)$$
$$=\frac{4}{x^2}-\frac{4}{x}+\frac{4}{x+1}$$
Putting all together, we have 
$$x^2-x+1+\frac{4}{x^2}-\frac{4}{x}+\frac{3}{x+1}$$
</s>