Solution (source code)

= Solution

The <chain rule> gives
$$
\boxed{f'(x)=-2x\exp(2-x^2).}
$$
Since $x^2\geq0$, the exponent is at most $2$, with equality precisely at $x=0$. The <exponential function> is increasing, so
$$
\boxed{\max_{x\in\mathbb R}f(x)=e^2,\qquad\text{attained at }x=0.}
$$
The sign of the <derivative>, positive for $x<0$ and negative for $x>0$, gives the same conclusion.