Step 1: Decompose the integrand using partial fractions. First, express the rational function as: \[ \frac{x^2 + x + 1}{(x + 2)(x^2 + 1)} = \frac{A}{x + 2} + \frac{Bx + C}{x^2 + 1} \]
Step 2: Multiply both sides by \( (x + 2)(x^2 + 1) \) to find the values of \( A \), \( B \), and \( C \).
Step 3: Solve for \( A \), \( B \), and \( C \) by equating coefficients of like powers of \( x \).
Step 4: Once the partial fraction decomposition is done, integrate each term separately. After integrating, the result is: \[ \int \frac{x^2 + x + 1}{(x + 2)(x^2 + 1)} \, dx = \ln |x + 2| + \frac{1}{2} \ln (x^2 + 1) + C. \]