integrate $\int \frac{x^4-16}{x^3+4x^2+8x}dx$ 
$$\int \frac{x^4-16}{x^3+4x^2+8x}dx$$

So I first started with be dividing $p(x)$ with $q(x)$ and got:
$$\int x-4+\frac{8x^2+32x-16}{x^3+4x^2+8x}dx=\frac{x^2}{2}-4x+\int \frac{8x^2+32x-16}{x^3+4x^2+8x}dx$$ 
Using partial sum I have received:
$$\int \frac{8x^2+32x-16}{x^3+4x^2+8x}dx=8\int -\frac{1}{4x}+\frac{5x}{4(x^2+4x+8)}+\frac{5}{x^2+4x+8} dx=-2ln|x|+8(\frac{5}{4}\int\frac{x}{(x^2+4x+8)} +5\int \frac{1}{x^2+4x+8})=-2ln|x| +10\int\frac{x}{(x^2+4x+8)}dx +40\int \frac{1}{x^2+4x+8}dx$$ 
How do I continue from here?
 A: You're almost there! Note that $$\frac{x}{x^2 + 4x + 8} =\frac{1}{2}\left( \frac{2x + 4 - 4}{x^2 + 4x + 8}\right) = \frac{1}{2}\left(\frac{2x + 4}{x^2 + 4x + 8}\right) - \frac{2}{x^2 + 4x + 8}$$
So that we have $$10\int\frac{x}{(x^2+4x+8)}dx +40\int \frac{1}{x^2+4x+8}dx = 5 \int \frac{2x + 4}{x^2 + 4x + 8} \, \mathrm{d}x + 20 \int \frac{\mathrm{d}x}{x^2 + 4x + 8}$$
which become a logarithmic and arctangent standard integral respectively. 
A: 
$\displaystyle \int \dfrac{1}{x^2+4x+8}dx$
How do I continue from here?

Observe that by writing
$$
x^2+4x+8=(x+2)^2+4
$$ and by making the change of variable
$$
t=2(x+2), \quad dx=\frac12dt, \quad x^2+4x+8=4(t^2+1)
$$ you are led to evaluate
$$
\int \dfrac{1}{x^2+4x+8}dx=\frac18\int\frac1{t^2+1}dt
$$ which is classic.

$\displaystyle \int \dfrac{x}{x^2+4x+8}dx$
How do I continue from here?

One may write
$$
 \int \dfrac{x}{x^2+4x+8}dx= \frac12\int \dfrac{2x+4}{x^2+4x+8}dx-2\int \dfrac{1}{x^2+4x+8}dx
$$that is $$
 \int \dfrac{x}{x^2+4x+8}dx=\frac12 \int \dfrac{(x^2+4x+8)'}{x^2+4x+8}dx-2\int \dfrac{1}{x^2+4x+8}dx
$$ then conclude with the first part.
A: HINT:
As  $x^2+4x+8=(x+2)^2+2^2$  and $\dfrac{d(x^2+4x+8)}{dx}=2(x+2)$
for $\dfrac{Ax+B}{x^2+4x+8},$  express it as $$a\cdot\dfrac{2(x+2)}{x^2+4x+8}+b\cdot\dfrac1{(x+2)^2+2^2}$$
Choose $x+2=2\tan y$ for the second term
