Integrate the functions in Exercises 1 to 23.
\( \frac{x^2 + x + 1}{(x + 1)^2 (x + 2)} \)Show solutionHide solution
We decompose the integrand into partial fractions. Write
\[ \frac{x^2+x+1}{(x+1)^2(x+2)}=\frac{A}{x+1}+\frac{B}{(x+1)^2}+\frac{C}{x+2}. \]Multiplying by \((x+1)^2(x+2)\), we get
\[ x^2+x+1=A(x+1)(x+2)+B(x+2)+C(x+1)^2. \]Comparing coefficients of \(x^2\), \(x\), and the constant term gives
\[ A+C=1,\qquad 3A+B+2C=1,\qquad 2A+2B+C=1. \]Solving these equations gives \(A=-2\), \(B=1\), and \(C=3\). Indeed,
\[ -2(x+1)(x+2)+(x+2)+3(x+1)^2=x^2+x+1, \]so the decomposition is correct:
\[ \frac{x^2+x+1}{(x+1)^2(x+2)}=-\frac{2}{x+1}+\frac{1}{(x+1)^2}+\frac{3}{x+2}. \]Therefore, for \(x\neq -1,-2\),
\[ \int \frac{x^2+x+1}{(x+1)^2(x+2)}\,dx = -2\ln|x+1|-\frac{1}{x+1}+3\ln|x+2|+C. \]Equivalently,
\[ \boxed{\int \frac{x^2+x+1}{(x+1)^2(x+2)}\,dx = \ln\!\left(\frac{|x+2|^3}{|x+1|^2}\right)-\frac{1}{x+1}+C}, \]where \(C\) is an arbitrary constant and the formula holds on any interval not containing the poles \(x=-1\) or \(x=-2\).