<s>[INST] Help solving $\int {\frac{8x^4+15x^3+16x^2+22x+4}{x(x+1)^2(x^2+2)}dx}$ $\displaystyle\int {\frac{8x^4+15x^3+16x^2+22x+4}{x(x+1)^2(x^2+2)}\,\mathrm{d}x}$
I used partial fractions, solved $A = 2, C = 3$.

$$\frac{A}{x} + \frac{B}{x+1} + \frac{C}{(x+1)^2} +\frac{(Dx+E)}{(x^2+2)}$$
\begin{align*}
&8x^4+15x^3+16x^2+22x+4\\
&\quad = A(x+1)^2(x^2+2)+B(x)(x+1)(x^2+2)+C(x)(x^2+2)+(Dx+E)(x)(x+1)^2
\end{align*}
Substitute in $x=0$ to get $4=A(1)(2)$, so  $A = 2$
$$6x^4+11x^3+10x^2+14x = B(x)(x+1)(x^2+2)+C(x)(x^2+2)+(Dx+E)(x)(x+1)^2$$
Substitute in $x=-1$ to get
$$6-11+10-14 = C(-1)(1+2)$$
so $-9=-3C$, thus $C=3$.
Leaving me what I have below:

Which brings me to where I am currently stuck.
$$6x^4 +8x^3 +10x^2+8x = B(x)(x+1)(x^2+2) + (Dx + E) (x) (x+1)^2$$
Is the next best move to use substitution to solve for $B$?
 [/INST] For kicks, I thought I provide the end result for checking:
${\huge{\displaystyle\int}} \! \dfrac {\rm{8x^4+15x^3+16x^2+22x+4}}{\rm{x(x+1)^{2}(x^2+2)}}~\mathrm{dx}~=~
{\huge{\displaystyle\int}} \! \dfrac {\rm{A}}{\rm{x}}+\dfrac {\rm B}{(\rm x+1)}+\dfrac {\rm C}{(\rm{x+1)^{2}}}+\dfrac {\rm{Dx+E}}{{\rm{(x^2+2)}}}~\mathrm{dx} $
$~~~~~~~~~~~~~~~
\left[ \begin{array}{ccccc}
\rm{a} \\
\rm{b} \\
\rm{c} \\
\rm{d} \\
\rm{e}
\end{array} \right] = \left[ \begin{array}{ccccc}
\rm{2} \\
\rm{4} \\
\rm{3} \\
\rm{2} \\
\rm{0}
\end{array} \right]~~~~~~~~~~\Rightarrow~~~~~~~~~~~~~~
={\huge{\displaystyle\int}} \! \dfrac {\rm 2}{\rm x}+\dfrac {\rm 4}{{\rm{(x+1)}}}+\dfrac {\rm 3}{{\rm{(x+1)^{2}}}}+\dfrac {\rm 2x+0}{{\rm{(x^2+2)}}}~\mathrm{dx}
$
$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
={\rm{2\ln|x|-4\ln(x+1)+\dfrac {3}{x+1}+\ln(x^2+2)+K}} 
$
$~~~~~~~~~~~\Big({\rm{\ln|x^2+2|\equiv \ln(x^2+2)}}~,~\because {\rm{x^2+2\gt 0~~\forall ~x \in \mathbb{R}}}\Big); ~$ 
via a substitution of the denominator for the last 3 integrals.
</s>