# 007B Sample Midterm 1, Problem 4 Detailed Solution

Evaluate the following integrals.

(a)   ${\displaystyle \int x^{2}e^{x}~dx}$

(b)   ${\displaystyle \int {\frac {5x-7}{x^{2}-3x+2}}~dx}$

Background Information:
1. Integration by parts tells us that
${\displaystyle \int u~dv=uv-\int v~du.}$
2. Through partial fraction decomposition, we can write the fraction
${\displaystyle {\frac {1}{(x+1)(x+2)}}={\frac {A}{x+1}}+{\frac {B}{x+2}}}$
for some constants ${\displaystyle A,B.}$

Solution:

(a)

Step 1:
We proceed using integration by parts.
Let  ${\displaystyle u=x^{2}}$  and  ${\displaystyle dv=e^{x}dx.}$
Then,  ${\displaystyle du=2xdx}$  and  ${\displaystyle v=e^{x}.}$
Therefore, we have
${\displaystyle \int x^{2}e^{x}~dx=x^{2}e^{x}-\int 2xe^{x}~dx.}$
Step 2:
Now, we need to use integration by parts again.
Let  ${\displaystyle u=2x}$  and  ${\displaystyle dv=e^{x}dx.}$
Then,  ${\displaystyle du=2dx}$  and  ${\displaystyle v=e^{x}.}$
Building on the previous step, we have
${\displaystyle {\begin{array}{rcl}\displaystyle {\int x^{2}e^{x}~dx}&=&\displaystyle {x^{2}e^{x}-{\bigg (}2xe^{x}-\int 2e^{x}~dx{\bigg )}}\\&&\\&=&\displaystyle {x^{2}e^{x}-2xe^{x}+2e^{x}+C.}\end{array}}}$

(b)

Step 1:
We need to use partial fraction decomposition for this integral.
Since  ${\displaystyle x^{2}-3x+2=(x-1)(x-2),}$  we let
${\displaystyle {\frac {5x-7}{(x-1)(x-2)}}={\frac {A}{x-1}}+{\frac {B}{x-2}}.}$
Multiplying both sides of the last equation by  ${\displaystyle (x-1)(x-2),}$
we get
${\displaystyle 5x-7=A(x-2)+B(x-1).}$
If we let  ${\displaystyle x=2,}$  the last equation becomes  ${\displaystyle 3=B.}$
If we let  ${\displaystyle x=1,}$  then we get  ${\displaystyle -2=(-1)A.}$  Thus,  ${\displaystyle A=2.}$
So, in summation, we have
${\displaystyle {\frac {5x-7}{x^{2}-3x+2}}={\frac {2}{x-1}}+{\frac {3}{x-2}}.}$
Step 2:
Now, we have

${\displaystyle \int {\frac {5x-7}{x^{2}-3x+2}}~dx=\int {\frac {2}{x-1}}~dx+\int {\frac {3}{x-2}}~dx.}$

Now, we use  ${\displaystyle u}$-substitution to evaluate these integrals.
For the first integral, we substitute  ${\displaystyle u=x-1.}$
For the second integral, the substitution is  ${\displaystyle t=x-2.}$
Then, we integrate to get

${\displaystyle {\begin{array}{rcl}\displaystyle {\int {\frac {5x-7}{x^{2}-3x+2}}~dx}&=&\displaystyle {\int {\frac {2}{u}}~du+\int {\frac {3}{t}}~dt}\\&&\\&=&\displaystyle {2\ln |u|+3\ln |t|+C}\\&&\\&=&\displaystyle {2\ln |x-1|+3\ln |x-2|+C.}\end{array}}}$

(a)     ${\displaystyle x^{2}e^{x}-2xe^{x}+2e^{x}+C}$
(b)     ${\displaystyle 2\ln |x-1|+3\ln |x-2|+C}$