# 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*}

HINT:

$$(x+2)^2=(x+4-2)^2=(x+4)^2-4(x+4)+4$$

$$\int e^x[f'(x)+f(x)]dx=e^xf(x)+K$$

Can you recognize $f(x)$ here?

• Thanks. Can you also help with the second integral? – 100110 Jul 30 '17 at 15:28
• @100110, You don't need to integrate by parts. Start as hinted – lab bhattacharjee Jul 30 '17 at 15:30
• Yes, but I'd like to know how one deals with an integral like that. Thank you. – 100110 Jul 30 '17 at 15:33
• @100110, Somehow we need to reach at the form $$e^x[f(x)+f'(x)]+$$ terms whose integration is simple enough See also : math.stackexchange.com/questions/687468/… math.stackexchange.com/questions/714204/… math.stackexchange.com/questions/1725611/… – lab bhattacharjee Jul 30 '17 at 15:37
• @100110 if you were given that second form of the integral you gave us and wanted to integrate it, it might just be easier to go backwards in integration by parts to get to your original form and then using this (or others) hint. To go backwards, think about applying integration by parts the same way, but switching your $u$ and $dv$ a little bit – user12345 Jul 30 '17 at 16:02

\begin{align*}\int e^x\left(\frac{x+2}{x+4}\right)^2\,\mathrm dx&=\int\frac1{(x+4)^2}e^x(x+2)^2\,\mathrm dx\\&=-\frac{e^x(x+2)^2}{x+4}+\int e^x(x+2)\,\mathrm dx\\&=-\frac{e^x(x+2)^2}{x+4}+e^x(x+2)-\int e^x\,\mathrm dx\\&=-\frac{e^x(x+2)^2}{x+4}+e^x(x+1)\\&=\frac{xe^x}{x+4}.\end{align*}