$\left(x^2+2\right) d y+2 x y d x=e^x\left(x^2+2\right) d x$
$\begin{aligned} & \left(x^2+2\right) d y=\left(e^x\left(x^2+2\right)-2 x y\right) d x \\ & \frac{d y}{d x}=\frac{e^x\left(x^2+2\right)}{x^2+2}-\frac{2 x}{x^2+2} y \\ & \frac{d y}{d x}+\frac{2 x}{x^2+2} y=e^x \\ & \mathrm{IF}=e^{\int \frac{2 x}{x^2+2} d x}=e^{\ln \left(x^2+2\right)} \\ & \mathrm{IF}=x^2+2 \\ & \therefore y \cdot \mathrm{IF}=\int \mathrm{Q} \cdot(\mathrm{IF}) d x+\mathrm{C} \\ & y \cdot\left(x^2+2\right)=\int e_{\text {II }}^x\left(x^2+2\right) d x+\mathrm{C} \\ & y\left(x^2+2\right)=\left(x^2+2\right) \cdot e^x-\int(2 x) \cdot e^x d x+\mathrm{C}\end{aligned}$
$\begin{aligned} & y\left(x^2+2\right)=e^x\left(x^2+2-2\right) \int x e^x d x+\mathrm{C} \\ & y\left(x^2+2\right)=e^x\left(x^2+2\right)-2\left[x \cdot e^x-\int e^x d x\right]+\mathrm{C} \\ & y\left(x^2+2\right)=e^x\left(x^2+2\right)-2 x e^x+2 e^x+\mathrm{C} \\ & y\left(x^2+2\right)=e^x\left(x^2-2 x+4\right)+\mathrm{C}\end{aligned}$