<s>[INST] 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?
 [/INST] $$\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.
</s>