Question:
Evaluate the following integral:
$\int \frac{x^{2}+x+1}{(x+1)^{2}(x+2)} d x$
Solution:
$I=\int \frac{x^{2}+x+1}{(x+1)^{2}(x+2)} d x$
$\frac{\mathrm{x}^{2}+\mathrm{x}+1}{(\mathrm{x}+1)^{2}(\mathrm{x}+2)}=\frac{\mathrm{A}}{\mathrm{x}+1}+\frac{\mathrm{B}}{(\mathrm{x}+1)^{2}}+\frac{\mathrm{c}}{\mathrm{x}+2}$
$x^{2}+x+1=A(x+1)(x+2)+B(x+2)+C(x+1)^{2}$
Put $x=-2$
$3=C$
$C=3$
Put $x=-1$
$1=B$
$B=1$
Equating coefficients of constants
$1=2 A+2 B+C$
$1=2 A+2+3$
$A=-2$
Thus,
$I=2 * \int \frac{\mathrm{dx}}{x+1}+(1) \int \frac{d x}{(x+1)^{2}}+3 \int \frac{d x}{x+2}$
$I=-2 \ln |x+1|-\left(\frac{1}{(x+1)}\right)+3 \ln |x+2|+C$