<s>[INST] 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 ?
 [/INST] You may use this:
$$\frac{5 x^2+3 x+2}{x (x+1)^2}=\frac{2}{x}+\frac{3}{x+1}-\frac{4}{(x+1)^2}$$
</s>