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 ?
 A: Got it !
What I missed is that I needed to re-divide
$$\frac{x^3}{x+1}$$
which give
$$x^2-x+1 - \frac{1}{x+1}$$
Now add it up to what I already had and we get correct result.
A: 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}$$
A: You can also do this using series expansions. If you have a rational function $R(x) = \frac{p(x)}{q(x)}$ then you can consider the expansion around each zero of the denominator $q(x)$. If you keep only the singular terms and subtract all of those from $R(x)$ for each singularity, then you are left with a rational function that doesn't have any singularities left, which must therefore be a polynomial. That polynomial can, of course, be found using long division, but also by expanding around x = infinity (which is more efficient, this is equivalent to synthetic division).
The advantage of this method is that you are computing each term directly, so errors made in computing one term don't get propagated to other terms.
In this case, the expansion around x = 0 yields:
$$R(x) = (x^5+4)\frac{1}{x^2}\frac{1}{1+x} = (x^5+4)\frac{1}{x^2}(1-x +\mathcal{O}(x^2)) = \frac{4}{x^2} - \frac{4}{x}+\mathcal{O}(1)$$
The expansion around x = -1 yields
$$R(x) = (x^5+4)\frac{1}{x^2}\frac{1}{1+x} = \frac{3}{x+1} + \mathcal{O}(1)$$
The sum of all the singular terms of the expansions around all the singularities is thus:
$$S(x) =  \frac{4}{x^2} - \frac{4}{x} + \frac{3}{x+1}$$
For large $x$ we can expand as follows:
$$R(x) = \frac{x^5+4}{x^3}\frac{1}{1+x^{-1}} = x^2 (1-\frac{1}{x} + \frac{1}{x^2})+\mathcal{O}(x^{-1}) = x^2 - x + 1+\mathcal{O}(x^{-1})$$
The expansion of $S(x)$ for large $x$ only contains negative powers of $x$, so we also have:
$$R(x) - S(x)= x^2 - x + 1+\mathcal{O}(x^{-1})$$
But we know that $R(x) - S(x)$ is a polynomial, therefore:
$$R(x) - S(x)= x^2 - x + 1$$
The partial fraction expansion is thus given by:
$$R(x) = x^2 - x + 1 +  \frac{4}{x^2} - \frac{4}{x} + \frac{3}{x+1}$$
