Evaluate an indefinite integral Find the value of 
$$\int{\frac{x^2e^x}{(x+2)^2}} dx$$
My Attempt: I tried to arrange the numerator as follows:
$$ e^xx^2 =  e^x(x+2-2)^2 $$ but that didn't help.
Any guidance on this problem will be very helpful.
 A: 
but that didn't help

It didn't? You will, after the division get
$$
e^x\Bigl(1-\frac{4}{2+x}+\frac{4}{(2+x)^2}\Bigr).
$$
Now, as it happen,
$$
\frac{d}{dx}\Bigl(-\frac{4}{2+x}\Bigr)=\frac{4}{(2+x)^2}.
$$
Can you perhaps use that, somehow? (I don't want to write the answer on your nose)
A: Another approach, let $u \mapsto x+2$ and expand
\begin{align*}
\int \frac{x^2e^x}{(x+2)^2}dx &= e^{-2} \int \frac{(u-2)^2 e^u}{u^2} \,du \\
 &= e^{-2} \int \left( \frac{4e^u}{u^2} - \frac{4e^u}{u} + e^u \right) \, du \\ 
 &= e^{-2} \left( \int e^u \,du -4 \int \frac{e^u}{u} - \frac{e^u}{u^2}\, du \right) \\ 
\end{align*}
now for the second integral, integrate each term by parts, $f_0=e^u$, $dg_0=u^{-2}$ and $f_1 = -u^{-1}$, $dg_1 = e^u$,
$$ = e^{-2} \left( e^u - \frac{4e^u}{u} \right) +c$$
$$ = e^{u-2} - \frac{4e^{u-2}}{u} +c$$
and substitute back in
$$ = e^x - \frac{4e^x}{x+2} +c$$
$$ = \frac{(x-2)e^x}{x+2} +c$$
A: Another method:
\begin{align}
\int \frac{x^2 \, e^{x}}{(x+2)^2} \, dx &= - \int x^2 \, e^{x} \, \frac{d}{dx} \left(\frac{1}{x+2}\right) \, dx \\
&= - \left[ \frac{x^2 \, e^{x}}{x + 2} \right] + \int x(x+2) \, e^{x} \cdot \frac{1}{x+2} \, dx \\
&= - \frac{x^2 \, e^{x}}{x + 2} + \int x \, e^{x} \, dx \\
&= - \frac{x^2 \, e^{x}}{x + 2} + (x-1) \, e^{x} + c_{0}\\
&= \left(\frac{x-2}{x+2} \right) \, e^{x} + c_{0}. 
\end{align}
A: Hint: let $f(x) = x^2e^x$ and $g(x) = \frac{1}{(x + 2)^2}$ and integrate by parts.
