Integration Involving Partial Fractions I have to integrate the following and I was having trouble with it because I am pretty new to the concept of using partial fractions. I did as much as I could and I need help in moving forward:
$$\int\frac{x^5+3x^2+1}{x^5+x^2}dx$$
I did some long division and got:
$$\int1+\frac{2x^2+1}{x^5+x^2}dx$$
Factored the denominator:
$$x^5+x^2$$
and got the following:
$$x^2(x+1)(x^2-x+1)$$
Now I think that I should have something like this, but I'm not sure:
$$\frac{A}{x^2}+\frac{B}{x+1}+\frac{C}{x^2-x+1}$$
Would appreciate any help. Thanks.
 A: The polynomial $x^2 - x + 1$ has discriminant $(-1)^2 - 4(1)(1) = -3 < 0$, so it has no real roots. According to the partial fractions recipe, there are unique real constants $A,B,C,D,E$ such that
$$\frac{2x^2+1}{x^5+x^2} = \frac{A}{x} + \frac{B}{x^2} + \frac{C}{x+1} + \frac{Dx+E}{x^2-x+1}$$
for all $x \in \mathbb{R}$.  In other words, you did not postulate a sufficiently general expression for the partial fractions decomposition, so -- except in the unlikely event that $A = D = 0$ -- you will not be able to achieve a decomposition in the form you have given.
I happened to cover partial fractions quite recently in a class I am teaching this semester.  A student asked me why you need a term like $\frac{A}{x}$.  My answer at the time was to think of taking a sum which did have a $\frac{A}{x}$ term, put it over a common denominator, and then apply a partial fractions decomposition: we would then be saying that there are some real constants $\alpha,\beta,\gamma,\delta$ such that
$$\frac{A}{x} + \frac{B}{x^2} + \frac{C}{x+1} + \frac{Dx+E}{x^2-x+1} = 
\frac{\alpha}{x^2} + \frac{\beta}{x+1} + \frac{\gamma x + \delta}{x^2-x+1},$$
which seems unlikely.  Actually I think I could say it a bit better: a general proper rational function with denominator $x^5+x^2$ is of the form
$$\frac{ax^4 + bx^3 + cx^2 + dx + e}{x^5+x^2},$$
thus there is in a sense a five parameter family of such things.  Therefore whatever your partial fractions decomposition should be, it should also have five parameters $A,B,C,D,E$.  That's a more convincing answer as to why your proposed expansion is (very probably) not achievable -- isn't it? -- you are trying to express a five parameter family of functions using only three parameters: no good.
This business with "parameters" can be made rigorous using the language of linear algebra, and in fact dimension-counting can be used to give a proof of the existence and uniqueness of the partial fraction decomposition.  See this note which I wrote just a few days ago.
A: As a rule of thumb, you should remember that the number of partial fractions that you need is the same as the degree of the polynomial appearing in the denominator. Therefore consider an expression like
$$\frac{A}{x} + \frac{B}{x^2} + \frac{C}{x+1} + \frac{Dx + E}{x^2 -x +1}$$
Thus repeated roots need extra terms (the presence of the $\dfrac{1}{x}$ and the $\dfrac{1}{x^2}$) and if the denominator of the partial fraction is an irreducible degree $2$ polynomial then you will need a linear factor on top. 
Why should you need $5$ partial fractions for a degree $5$ denominator? Intuitively, the reason is that you want to get a system that has the same number of equations as unknowns. When you set up the equations to solve for the coefficients, a degree $5$ polynomial gives you $5$ equations, so you want enough coefficients to ensure that there is one and only one solution.
Edit: to answer the question in the comment, let me give you an example of why the extra partial fractions are necessary:
Consider the function 
$$\frac{3x+2}{x^2(x+1)}$$
Let's try to do a partial fractions decomposition. If I tried to write
$$\frac{3x+2}{x^2(x+1)} = \frac{A}{x^2} + \frac{B}{x+1}$$
Then this gives me the equation
$$\frac{3x+2}{x^2(x+1)} = \frac{Bx^2 + Ax + A}{x^2(x+1)}$$
Which would imply that $B= 0$, $A= 2$ and $A=3$ (Notice that I have three equations and only two constants $A$ and $B$). This is, of course, impossible. This means that I need to add in another term when I write down the partial fraction decomposition in the first place. I can get around this by adding in an extra term for each repeated root. The correct equation is:
$$\frac{3x+2}{x^2(x+1)} = \frac{A}{x} + \frac{B}{x^2} + \frac{C}{x+1}$$
Now in this case it is possible to determine $A$, $B$, $C$. 
See also Pete's more general answer- I was writing this as he finished his edit.
