Linear First Order ODE/y' + y = 2 x exp -x + x^2

Theorem
The linear first order ODE:
 * $(1): \quad y' + y = 2 x e^{-x} + x^2$

has the solution:
 * $y = x^2 e^{-x} + x^2 - 2 x + 2 + C e^{-x}$

Proof
$(1)$ is in the form:
 * $\dfrac {\mathrm d y}{\mathrm d x} + P \left({x}\right) y = Q \left({x}\right)$

where:
 * $P \left({x}\right) = 1$

Thus:

Thus from Solution by Integrating Factor, $(1)$ can be rewritten as:
 * $\dfrac {\mathrm d} {\mathrm d x} e^x y = 2 x + x^2 e^x$

and the general solution is:
 * $e^x y = x^2 + e^x \left({x^2 - 2 x + 2}\right) + C$

or:
 * $y = x^2 e^{-x} + x^2 - 2 x + 2 + C e^{-x}$