Given. (a) A first-order linear ODE with variable coefficient $x$ and forcing $2xe^{-x^2}$. (b) A homogeneous, constant-coefficient second-order ODE.
Find. The general solution $y(x)$ in each case.
Approach. (a) Solve by an integrating factor $\mu(x)=e^{\int x\,dx}$. (b) Solve the characteristic (auxiliary) equation and combine the two real exponential modes.
(a) Integrating factor. The equation $y'+xy=2xe^{-x^2}$ has integrating factor
$$\mu(x)=e^{\int x\,dx}=e^{x^2/2}.$$
(a) Multiply through and integrate. Multiplying both sides by $\mu$,
$$\left(e^{x^2/2}y\right)'=2xe^{-x^2}\cdot e^{x^2/2}=2xe^{-x^2/2}.$$
The right side integrates directly, since $\dfrac{d}{dx}e^{-x^2/2}=-xe^{-x^2/2}$:
$$\int 2xe^{-x^2/2}\,dx=-2e^{-x^2/2}+C.$$
So $e^{x^2/2}y=-2e^{-x^2/2}+C$.
(a) Solve for $y$. Dividing by $e^{x^2/2}$,
$$y(x)=\boxed{Ce^{-x^2/2}-2e^{-x^2}}$$
(Check: $y'=-Cxe^{-x^2/2}+4xe^{-x^2}$, and $y'+xy=-Cxe^{-x^2/2}+4xe^{-x^2}+Cxe^{-x^2/2}-2xe^{-x^2}=2xe^{-x^2}$ ✓.)