Solve $\int e^{x^2+x}(4x^3+4x^2+5x+1)dx$ One of the solutions tried to write the integral a
$$\int e^{x^2+x}((2x+1)p(x) + p’(x))dx$$
Where $p(x)=2x^2+bx+c$
I have no idea why they chose the lead coefficient to be $2$.
Going with this, $b=1$ and $c=0$
So
$$\int e^{x^2+x} ((2x+1)(2x^2+x)+4x+1)dx $$
Now even after substituting $x^2+x=t$, the integration still seems to be mess, not in the form of the desired $\int e^t(f(t)+f’(t))dt$ form.
Is there a better solution or a better explanation for this one?
 A: $$\begin{align}
\int e^{x^2+x}(4x^3+4x^2+5x+1)dx &= \int e^{x^2+x}(4x^3 + 2x^2 + 2x^2 + x + 4x + 1)dx\\
&= \int e^{x^2+x}(2x+1)(2x^2 + x) +  e^{x^2+x}(4x+1)dx\\
&= \int e^{f(x)}(f'(x)g(x) + g'(x)) dx  
\end{align}$$
where $f(x) = x^2 + x$ and $g(x) = 2x^2 + x$. You should be able to see (integration by parts is one way) that
$$\int e^{f(x)}(f'(x)g(x) + g'(x)) dx  = e^{f(x)} g(x) + C$$
To summarize,
$$\int e^{x^2+x}(4x^3+4x^2+5x+1)dx = e^{x^2 + x} (2x^2 + x) + C$$

Comments on your solution: 
Great work, you almost completed it! It's worth noting that instead of $\int e^{t} (f(t) + f'(t)) dt$, you really want a polynomial in the exponent. Take $f(x) = x^2 + x$ (the obvious choice) and see where you can get with differentiating $e^{f(x)}g(x)$? That's how I would reverse engineer the solution.  Once you know $g(x)$, the game is over.
A: Substitute $x+\frac12 =t$ to rewrite the integral as
$$\int e^{x^2+x}(4x^3+4x^2+5x+1)dx
=e^{-\frac14}\int e^{t^2}(4t^3-2t^2+4t-1)dt
$$
and note
$$\int e^{t^2}(2t^2+1)dt=t e^{t^2},\>\>\>\>\>
\int e^{t^2}(t^3+t)dt=\frac12t^2 e^{t^2}
$$
A: As you wrote, we have : \begin{aligned}\small\int{\mathrm{e}^{x^{2}+x}\left(4x^{3}+4x^{2}+5x+1\right)\mathrm{d}x}&\small =\int{\mathrm{e}^{x^{2}+x}\left(\left(2x+1\right)\left(2x^{2}+x\right)+4x+1\right)\mathrm{d}x}\\ &\small =2\int{\mathrm{e}^{x^{2}+x}\left(2x+1\right)\left(x^{2}+x\right)\mathrm{d}x}-\int{x\,\mathrm{e}^{x^{2}+x}\left(2x+1\right)\mathrm{d}x}+\int{\mathrm{e}^{x^{2}+x}\left(4x+1\right)\mathrm{d}x}\\ &\small =2\int{y\,\mathrm{e}^{y}\,\mathrm{d}y}-\left(\left[x\,\mathrm{e}^{x^{2}+x}\right]-\int{\mathrm{e}^{x^{2}+x}\,\mathrm{d}x}\right)+\int{\mathrm{e}^{x^{2}+x}\left(4x+1\right)\mathrm{d}x}\\ &\small =2\,\mathrm{e}^{y}\left(y-1\right)-x\,\mathrm{e}^{x^{2}+x}+2\int{\mathrm{e}^{x^{2}+x}\left(2x+1\right)\mathrm{d}x}\\ &\small =2\,\mathrm{e}^{x^{2}+x}\left(x^{2}+x-1\right)-x\,\mathrm{e}^{x^{2}+x}+2\,\mathrm{e}^{x^{2}+x}+C\\ \small\int{\mathrm{e}^{x^{2}+x}\left(4x^{3}+4x^{2}+5x+1\right)\mathrm{d}x}&\small =x\,\mathrm{e}^{x^{2}+x}\left(2x+1\right) + C\end{aligned}

*

*In the second line, we added the $ x $ we needed to complete $ 2\left(x^{2}+x\right) $, then we substracted it.


*In the third line we substituted $ y=x^{2}+x $, and we integrated $ \int{x\,\mathrm{e}^{x^{2}+x}\left(2x+1\right)\mathrm{d}x} $ by parts.
