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. 
Anyways, our decomposition must be
\begin{equation*}
    \frac{3x^3+ 7x^2+ 5x+ 3}{(x+1)^2(x^2+1)}
     =  \frac{1}{(x+1)} +  \frac{1}{(x+1)^2}+  \frac{2x+1}{(x^2+1)}
     \,,
\end{equation*}
and we can now easily evaluate the integral:
\begin{align*}
   &\int \frac{3x^3+ 7x^2+ 5x+ 3}{(x+1)^2(x^2+1)}\,\mathrm{d}x
   \\\\=\quad  &\int\left(\frac{1}{(x+1)} + \frac{1}{(x+1)^2}+ \frac{2x+1}{(x^2+1)}\right)\,\mathrm{d}x
   \\\\ =\quad  &\int\frac{1}{(x+1)}\,\mathrm{d}x + \int\frac{1}{(x+1)^2}\,\mathrm{d}x+  \int\frac{2x+1}{(x^2+1)}\,\mathrm{d}x
      \\\\ = \quad &\int\frac{1}{(x+1)}\,\mathrm{d}x + \int\frac{1}{(x+1)^2}\,\mathrm{d}x+  \int\frac{2x}{(x^2+1)}\,\mathrm{d}x   +  \int\frac{1}{(x^2+1)}\,\mathrm{d}x
   \\\\ =\quad  &\ln|x+1| - \frac{1}{x+1}+ \ln|x^2+1| + \arctan(x) + C
\end{align*}
And of course if we wanted to, we could go crazy with logarithms and write this as
\begin{align*}
   &\ln|x+1| - \frac{1}{x+1}+ \ln|x^2+1| + \arctan(x) + C
   \\\\=\quad &\ln\left|C(x^3+x^2+x+1)e^{\arctan(x) - \frac{1}{x+1}}\right| 
   \,.
\end{align*}
