# An example of evaluating an integral using partial fraction decomposition

How do you evaluate the integral \begin{equation*} \int \frac{3x^3+ 7x^2+ 5x+ 3}{(x+1)^2(x^2+1)}\,\mathrm{d}x \,? \end{equation*}

This is just an exercise that I wanted to have typed up for my class. Maybe it'll help other students to see an example worked out.

Notice that if we were to expand the denominator of the integrand, the highest power of $x$ would be $4$, which is less than the highest power in the numerator. So this expression is ripe to be rewritten with partial fraction decomposition. Since $x^2+1$ cannot be factored, the decomposition must look like \begin{equation*} \frac{3x^3+ 7x^2+ 5x+ 3}{(x+1)^2(x^2+1)} = \frac{A}{(x+1)} + \frac{B}{(x+1)^2}+ \frac{Cx+D}{(x^2+1)} \,. \end{equation*} Multiplying out the right-hand side, we get that \begin{align*} &\frac{A}{(x+1)} + \frac{B}{(x+1)^2}+ \frac{Cx+D}{(x^2+1)} \\\\=\quad &\frac{A(x+1)(x^2+1) + B(x^2+1) + (Cx+D)(x+1)^2}{(x+1)^2(x^2+1)} \\\\=\quad &\frac{(A+C)x^3+(A+B+2C+D)x^2+(A+C+2D)x+(A+B+D)}{(x+1)^2(x^2+1)} \,. \end{align*} Equating the coefficients in this expression with the coefficients in the original expression that we want this one to be equal to, we get the following system of equations: \begin{cases} A+C=3 \\ A+B+2C+D=7 \\ A+C+2D = 5 \\ A+B+D=3 \end{cases} Now we've just got to play around with these equations to solve for our unknowns. This can be done many ways. One way to do it would be to notice that the second and fourth lines are quite similar. If we take the second line and subtract the fourth line, we get that $2C=4$, so $C=2$. Now looking at line one, $A=1$. Looking at the third line, $D=1$. And since $A=D=1$, looking at the fourth line, $B=1$ too. These values for $A$,$B$,$C$, and $D$ are very nice. It's like someone planned this problem to work out nicely.