TITLE: Difficult definite integration $\int_{-2}^{0}\frac{x^2 + x - 5}{(x-1)^2}e^x\,\mathrm dx$
QUESTION [6 upvotes]: I found an integral in a contest that seems very difficult to compute. The answer is $-2$, however, I do not know how to arrive at this answer.
$$\int_{-2}^{0}\frac{x^2 + x - 5}{(x-1)^2}e^x\,\mathrm dx$$
At first I tried to make the substitution $u = x - 1$, but I did not get anywhere. I also tried to expand the denominator and perform synthetic division, which did not help so much either.
Also, I don't think it is possible to do partial fraction decomposition since the degree of the denominator is equal to the degree of the numerator.

Attempt with substitution (Moo's help) -
Let $u = x - 1$. Then, $du = 1$
$$\begin{align}
I &= \int_{-2}^{0} \frac{x^2 + x - 5}{(x - 1)^2} e^x\,\mathrm dx =\\
&= \int_{-2}^{0} \frac{x^2 + x - 5}{u^2} e^{u+1}\,\mathrm du =\\
&= \int_{-2}^{0} \frac{e^{u+1}(x^2 + x - 5)}{u^2}\,\mathrm du
\end{align}$$
Now, $x = u + 1$, $x^2 = u^2 + 2u + 2$ and therefore
$$I = \int_{-3}^{-1} \frac{e^{u+1}(u^2 + 3u - 2)}{u^2}\mathrm du = e \int_{-3}^{-1} e^{u}\frac{u^2 + 3u - 3}{u^2}\mathrm du$$

REPLY [4 votes]: Integration by part we get
\begin{align*}
\int\frac{x^2 + x - 5}{(x-1)^2}e^x \, \mathrm{d}x&=-\frac{x^2 + x - 5}{x-1}e^x +\int e^{x}\left ( x+4 \right )\, \mathrm{d}x  \\
&=-\frac{x^2 + x - 5}{x-1}e^x+e^{x}\left ( x+3 \right )\\
&=\frac{x+2}{x-1}e^{x}
\end{align*}
Then you can take it from here.

REPLY [3 votes]: Substituting for $u=x-1$, we get, $$I=\int_{-2}^{0} \frac {x^2-x+5}{(x-1)^2} e^x dx =\int_{-3}^{-1} \frac {u^2+3u-3}{u^2} e^{u+1} du $$ $$\Rightarrow I=e [\int_{-3}^{-1} [3 (\frac {e^u}{u} -\frac {e^u}{u^2}) du] +\int_{-3}^{-1} e^u du] =e [3I_1-3I_2 +I_3] $$ Now we have $$I_1-I_2 =\int_{-3}^{-1}(\frac {e^u}{u}-\frac {e^u}{u^2}) du =\int_{-3}^{-1} d (\frac {e^u}{u}) =\frac {e^u}{u} \mid_{-3}^{-1} $$ We see that $I_3$ is easy to solve. Finally the answer is  $-2$. Hope it helps.