Partial fraction decomposition makes it possible to solve integrals of a certain type.
For instance, there's no way I can solve the second integral you gave in its current form, but I CAN solve it using the second form.
Integral (A/(x+3) + B/(x+5) + C/(x+5)^2)dx
We can separate this into three integrals
Integral (A/(x+3))dx + Integral (B/(x+5))dx + Integral (C/(x+5)^2)dx
And then pull out the constants (since they get in our way of integration sometimes).
A * Integral (1/(x+3))dx + B * Integral (1/(x+5))dx + C * Integral(1/(x+5)^2)dx
I *know* the integral of 1/(x+3); that's just ln |x+3|. Also, I know the integral of 1/(x+5)^(2); since x + 5 is linear, we just apply the reverse power rule for derivatives, and convert this to (x+5)^(-2), to get (x+5)^(-1)/(-1), or -1/(x+5). So now our answer is
A * ln|x+3| + B ln |x+5| + C (-1/(x+5)) + D for some constant D.
Notice that using partial fraction decomposition makes integration actually possible. There's no way we can solve the original question by u substitution, parts, or any of the other existing rules. We have to decompose it into smaller parts which we can actually solve.
The second step is to solve for A, B, and C. We know that
(x-1)/(x+3)(x+5)^2 = (A/x+3)+ B/(x+5) +C/(x+5)^2
is true for _all_ x. But first, let's multiply both sides by (x+3)(x+5)^2. This cancels out all the denominators, and we're left with:
x - 1 = A(x+5)^2 + B(x+3)(x+5) + C(x+3)
Since this is true for all x, let's let x = -5. Then
-5 -1 = A(0)^2 + B(-2)(0) + C(-2)
-6 = C(-2)
C = 1/3
So we at least have our C value now.
Now, let x = -3. Then
-3 - 1 = A(-3+5)^2 + B(0)(2) + C(0)
-4 = A(2)^2
-4 = 4A
A = -1
To solve for B is a bit trickier. We have to actually multiply everything out.
x - 1 = A(x+5)^2 + B(x+3)(x+5) + C(x+3)
x - 1 = A(x^2 + 10x + 25) + B(x^2 + 8x + 15) + Cx + 3C
x - 1 = Ax^2 + 10Ax + 25A + Bx^2 + 8Bx + 15B + Cx + 3C
And now, we group together like terms
x - 1 = (A+B)x^2 + (10A + 8B + C)x + (25A + 15B + 3C)
Now, we compare it to the left hand side, and equate it. By the rules of partial fractions, the coefficients on the left hand side and the right hand side MUST match. There's no x^2, so we assume there's a 0x^2 on the left hand side.
0x^2 + x - 1 = (A+B)x^2 + (10A + 8B + C)x + (25A + 15B + 3C)
And now we match:
A+B = 0
10A + 8B + C = 1
25A + 15B + 3C = -1
Since we solved for A earlier (it was -1), we can solve for the unknown B, using the first and simplest equation.
-1 + B = 0, so B = 1
So now, A = -1, B = 1, and C = 1/3
Now, we plug them back into here:
A * ln|x+3| + B ln |x+5| + C (-1/(x+5)) + D
(-1)ln|x+3| + (1) ln|x+5| + (1/3) (-1/(x+5)) + D
- ln |x+3| + ln|x+5| - (1/3) (1/(x+5)) + D
To answer your other question, when to use Cx + D in the numerator, it is when the partial fraction decomposition creates something that's not factorable.
For instance, if you have x^2 + 4, you can't factor it, and so you use (Cx + D)/(x^2+4). Had it been x^2 - 4, then this is something you CAN factor, as it becomes (x-2)(x+2) and then you do your A/(x-2) + B/(x+2) as normal.