# 007B Sample Midterm 1, Problem 4 Detailed Solution

Evaluate the following integrals.

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

(a)

Step 1:
We proceed using integration by parts.
Let  $u=x^{2}$ and  $dv=e^{x}dx.$ Then,  $du=2xdx$ and  $v=e^{x}.$ Therefore, we have
$\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  $u=2x$ and  $dv=e^{x}dx.$ Then,  $du=2dx$ and  $v=e^{x}.$ Building on the previous step, we have
${\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  $x^{2}-3x+2=(x-1)(x-2),$ we let
${\frac {5x-7}{(x-1)(x-2)}}={\frac {A}{x-1}}+{\frac {B}{x-2}}.$ Multiplying both sides of the last equation by  $(x-1)(x-2),$ we get
$5x-7=A(x-2)+B(x-1).$ If we let  $x=2,$ the last equation becomes  $3=B.$ If we let  $x=1,$ then we get  $-2=(-1)A.$ Thus,  $A=2.$ So, in summation, we have
${\frac {5x-7}{x^{2}-3x+2}}={\frac {2}{x-1}}+{\frac {3}{x-2}}.$ Step 2:
Now, we have

$\int {\frac {5x-7}{x^{2}-3x+2}}~dx=\int {\frac {2}{x-1}}~dx+\int {\frac {3}{x-2}}~dx.$ Now, we use  $u$ -substitution to evaluate these integrals.
For the first integral, we substitute  $u=x-1.$ For the second integral, the substitution is  $t=x-2.$ Then, we integrate to get

${\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)     $x^{2}e^{x}-2xe^{x}+2e^{x}+C$ (b)     $2\ln |x-1|+3\ln |x-2|+C$ 