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.
 A: 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.
A: It should be $A=3,B=2,C=1$ and you get:
$$\int \frac{3}{x+1} dx + \int \frac{2x+2}{x^2+2x+5} dx -\int \frac{1}{x^2+2x+5}dx$$
The second is easy by using $u=x^2+2x+5$ and other answerers have covered the last.
The key is writing $\frac{2x+1}{x^2+2x+5} = \frac{2x+2}{x^2+2x+5} - \frac{1}{x^2+2x+5}$.
It's probably easier to just set $u=x+1$ at the start. Then you get:
$$\int\frac{5(u-1)^2+9(u-1)+16}{u(u^2+4)}\,du=\int\frac{5u^2-u+12}{u(u^2+4)}dx$$
Then write:
$$\frac{5u^2-u+12}{u(u^2+4)} = \frac{A}{u} + \frac{Bu+C}{u^2+4}$$
Giving $$A=3,B=2,C=-1$$, and the integrals:
$$\int\left(\frac{3}{u} + \frac{2u}{u^2+4} - \frac{1}{u^2+4}\right)\,du$$
A: (Just working on the last integral, but not checking the partial fractions.)  Complete the square:
$$\int \frac{dx}{x^2+2x+5} = \int \frac{dx}{(x+1)^2 + 4}$$
Now, substitute $x+1 = 2\tan(t)$.  So, $dx = 2\sec^2 t\;dt$.  Thus:
$$\begin{align}
\int \frac{dx}{(x+1)^2 + 4} &= \int\frac{2\sec^2(t)dt}{4(\tan^2t + 1)} \\
&= \frac{1}{2}\int\frac{\sec^2 t\; dt}{\sec^2t} \\
&= \frac{1}{2}\int 1\; dt\\
&= \cdots
\end{align}$$
