The maximum occurs when $x=0$.
To find the maximum, we can take the derivative of $f(x)$ and set it equal to zero. The derivative of $f(x)$ is $f'(x) = 2xe^{-x} – x^2e^{-x} = x(2e^{-x} – x)$. Setting $f'(x)=0$, we get $x(2e^{-x} – x) = 0$. Solving for $x$, we get $x=0$ or $x=2e^{-x}$.
Since $e^{-x} > 0$ for all real numbers, $2e^{-x} > x$ for all real numbers except $x=0$. Therefore, the only solution to $x(2e^{-x} – x) = 0$ is $x=0$.
We can also find the maximum by looking at the graph of $f(x)$. The graph of $f(x)$ is shown below.
[asy]
unitsize(1 cm);
real ticklen=3;
real tickspace=2;
real axisarrowsize=0.14inch;
real tickdown=-0.14inch;
real wholetickdown=-0.2inch;
real wholetickdownlength=0.14inch;
real wholetickdownbase=-0.24inch;
real wholetickdownextend=0.14inch;
real wholetickdownextendbase=-0.34inch;
real tickdownbase=-0.14inch;
real tickdownextend=0.14inch;
real tickdownextendbase=-0.24inch;
real ticklength=0.14inch;
real axispen=black+0.7bp;
real tickpen=black+0.7bp;
real xmin=-2;
real xmax=2;
real ymin=-2;
real ymax=2;
real xstep=0.2;
real ystep=0.2;
draw((xmin,0)–(xmax,0),axispen);
draw((0,ymin)–(0,ymax),axispen);
label(“$x$”,(xmax,-0.1),E);
label(“$y$”,(-0.1,ymax),N);
for (int i=xmin+xstep; i<xmax; i+=xstep) {
draw((i,0.01)–(i,-0.01));
}
for (int i=ymin+ystep; i<ymax; i+=ystep) {
draw((0.01,i)–(-0.01,i));
}
real g(real x) {
return x^2*exp(-x);
}
draw(graph(g,xmin,xmax),red);
draw((0,g(0))–(0.1,g(0)),dashed);
label(“$f(x)$”,(1.2,1.2),S);
label(“$y=x^2e^{-x}$”,(0.5,1.2),S);
label(“$x=0$”,(0,g(0)),S);
[/asy]
As you can see, the graph of $f(x)$ reaches its maximum at $x=0$.