Having trouble solving $\int\frac{5x^2+3x+2}{x(x+1)^2}$ I've first transformed the integral to
$$\int\frac{5x^2+3x+2}{x(x^2+2x+1)}dx$$
Which gave me
$$\frac{A}{x}+\frac{Bx+C}{x^2+2x+1}$$
$$=\frac{A(x^2+2x+1)+Bx^2+Cx}{x(x^2+2x+1)}$$
$$\frac{5x^2+3x+2}{x(x^2+2x+1)}=\frac{(A+B)x^2+(2A+C)x+A)}{x(x^2+2x+1)}$$
So I've found the corresponding variables
$$A = 2$$
$$A+B = 5,  B = 3$$
$$2A+C=3, C=-1$$
So the final integral is
$$2\int\frac{dx}{x}+3\int\frac{xdx}{x^2+2x+1}-\int\frac{dx}{x^2+2x+1}$$
$$=2ln(x) -ln(x^2+2x+1)+\frac{3}{x+1}+3ln(x+1)$$
However, the expected answer is 
$$2ln(x)+3ln(x+1)+\frac{4}{x+1}$$
What is my error ?

you can see that $$\frac{5x^2 + 3x+2}{x(x+1)^2} = \frac 2 x + \frac{B}{x+1} - \frac 4{(x+1)^2}$$ by looking at the behavior of the two sides near the singularities $x = 0, x = -1.$  to find $B,$ put $x = 1.$ you will find $B = 3.$
you can now integrate $$ \int \frac{5x^2 + 3x+2}{x(x+1)^2} \, dx = 2 \ln x + 3 \ln(x+1) + \frac 4{x+1} + C$$
