Need help integrating $\int e^x(\frac{x+2}{x+4})^2 dx $ I have simplified the problem a bit using integration by parts, with $u = e^x(x+2)^2$ and $v = 1/(x+4)^2$ but I'm then stuck with how to integrate this:
$$\int\frac{e^x(x^2+4x+8)}{x+4}dx. $$
I've considered substituting $t = e^x$, but this doesn't seem to make the problem any easier.

Since 
\begin{align*}
\left(\frac{x+2}{x+4}\right)^2 &= \frac{x^2+4x+4}{(x+4)^2} \\
&= \frac{4}{(x+4)^2}+\frac{x(x+4)}{(x+4)^2} \\
&= \frac{4}{(x+4)^2}+\frac{x}{x+4} \\
&=f'(x)+f(x), \\ 
\end{align*}
let 
$$
\color{blue}{f(x)=\frac{x}{x+4}}.
$$  
Now for $C$ constant, since 
$$
\dfrac{d}{dx}(e^x f(x)+C) = (e^x f(x)+C)' = e^x f'(x)+e^x f(x), 
$$
we have 
$$
\int \left(e^x f'(x)+e^x f(x)\right)dx = e^x f(x)+C. 
$$
So for the above indefinite integral, 
$$
\begin{align*}
\color{green}{\int e^x\left(\frac{x+2}{x+4}\right)^2 dx} 
&= \int e^x \left(f'(x) + f(x)\right) dx  \\ 
&= \int \left(e^x f'(x)+e^x f(x)\right) dx \\
&= e^x f(x)+C \\ 
&= \color{green}{\frac{x\: e^x}{x+4} + C}.
\end{align*}
$$
