<s>[INST] Integrate by partial fraction decomposition $$\int\frac{5x^2+9x+16}{(x+1)(x^2+2x+5)}dx$$
Here's what I have so far...
$$\frac{5x^2+9x+16}{(x+1)(x^2+2x+5)} = \frac{\mathrm A}{x+1}+\frac{\mathrm Bx+\mathrm C}{x^2+2x+5}\\$$
$$5x^2 + 9x + 16 = \mathrm A(x^2+2x+5) + (\mathrm Bx+\mathrm C)(x+1)=\\$$
$$\mathrm A(x^2+2x+5) + \mathrm B(x^2+x)+\mathrm C(x+1)=\\$$
$$(\mathrm A+\mathrm B)x^2 + (2\mathrm A + \mathrm B + \mathrm C)x + (5\mathrm A+\mathrm C)\\$$
$$\mathrm A=-3,\;\mathrm B=8,\;\mathrm C = 31$$
$$$$
$$\int\frac{5x^2+9x+16}{(x+1)(x^2+2x+5)}dx = \int\bigg(-\frac{3}{x+1}+\frac{8x+31}{x^2+2x+5}\bigg)dx\Rightarrow$$
$$\int-\frac{3}{x+1}dx +\int\frac{8}{x^2+2x+5}dx+\int\frac{31}{x^2+2x+5}dx $$
Hopefully I've got it correct until this point (if not, someone point it out please!). I can do the first integration by moving the -3 out and using $u=x+1$ to get 
$$-3 \ln(x+1)$$
but I'm stuck on the next two.
 [/INST] PS:
Thomas Andrews says the values of $A,B,C$ are in error.  I haven't checked those, but the technique outlined below still works if different numbers are involved.
end of PS
$$
\int\frac{8x+31}{x^2+2x+5}\,dx
$$
First let $w=x^2+2x+5$ so that $dw=(2x+2)\,dx$.  Then we have
$$
\int\frac{8x+31}{x^2+2x+5}\,dx = 4\int\frac{2x+2}{x^2+2x+5}\,dx+ \int\frac{23\,dx}{x^2+2x+5}
$$
Use the substitution to handle the first integral. Then
$$
\overbrace{\int\frac{23\,dx}{x^2+2x+5} = \int\frac{23\,dx}{(x+1)^2+2^2}}^{\text{completing the square}} = \frac{23}2\int\frac{dx/2}{\left(\frac{x+1}{2}\right)^2+1} = \frac{23}2 \int\frac{du}{u^2+1}
$$
and get an arctangent.
</s>