Integration of rational functions.. Some rational function is giving me some trouble...
\begin{aligned} 
\ \int \frac {x^2-9x+16}{(x-1)(x^2+6x-7)}  dx
\end{aligned}
I simplified it like so:
\begin{aligned} 
\ \int \frac {x^2-9x+16}{(x-1)^2(x+7)}  dx
\end{aligned}
If I get it right I can transform it into this:
\begin{aligned} 
\ \int \frac {A}{(x-1)} + \frac {B}{(x-1)^2} + \frac {C}{(x+7)}    dx
\end{aligned}
And then I get this:
\begin{aligned} 
\ Ax^2 +6Ax-7A+Bx+Cx^2-2Cx+C = x^2-9x+16
\end{aligned}
So I forgot how to get ABC values. Could somebody remind me this?
I am showing all the steps because I am not 100% confident that with have not made any mistakes.
 A: You have:
$$
{x^2-9x+16\over(x-1)^2(x+7)}={A\over x-1\vphantom{(^2}}+{B\over (x-1)^2}+{C\over x+7\vphantom{(^2}}.
$$
Clearing denominators in the above equality  gives:
$$\tag{1} 
x^2-9x+16=A(x-1)(x+7)+B(x+7)+C(x-1)^2.
$$
This holds for all $x$. We can be clever and take advantage of this. Set $x=1$ in $(1)$ to obtain
$$
8=B\cdot 8.
$$
So $B=1$.  
Set $x=-7$ in $(1)$ to obtain
$$
128=C\cdot64.
$$
So $C=2$.
Then, substituting the  known values Of $B$ and $C$ into $(1)$, we have
$$\tag{2}
x^2-9x+16=A(x-1)(x+7)+ (x+7)+2(x-1)^2.
$$
Putting the right hand side of $(2)$ in standard form gives:
$$
x^2-9x+16=(A+2)x^2 +(6A-3)x +(9-7A);
$$
and we see that $A=-1$. (All we really had to do here, is note that the $x^2$ term on the right hand side of $(2)$ is $Ax^2+2x^2$. Then, since the $x^2$ term on the left hand side of $(2)$ is $x^2$, we'd know $A+2=1$; whence $A=-1$.) 

Alternatively, as I suggested in the comments, expand the right hand side of $(1)$ and write the resulting quadratic in standard form:
$$
x^2-9x+16=(A+C)x^2+(6A+B-2C)x+(-7A+7B+C ).
$$
Then equate the $x^2$, $x$, and constant coefficients of  the right and left hand sides of the above equality:
$$
\eqalign{
1&=A+C\cr
-9&=6A+B-2C\cr
16&=-7A+7B+C.
} 
$$
This gives you three linear equations in the unknowns $A$, $B$, and $C$. Solve the system for the unknowns.  (I prefer the first method as it reduces the chances (big for me) of making the types of errors that the second method is prone to.)
