To find the maximum of the function \( f(x) = x^2 e^{-x} \), we first need to find its derivative with respect to \( x \). This is done by applying the product rule, as the function is a product of two functions: \( x^2 \) and \( e^{-x} \).
The derivative of \( f(x) \) is given by:
\[
f'(x) = \frac{d}{dx}\left(x^2 e^{-x}\right)
\]
Using the product rule, we get:
\[
f'(x) = \frac{d}{dx}(x^2) \cdot e^{-x} + x^2 \cdot \frac{d}{dx}(e^{-x})
\]
\[
f'(x) = 2x \cdot e^{-x} + x^2 \cdot (-e^{-x})
\]
\[
f'(x) = e^{-x} (2x - x^2)
\]
Now, to find the critical points, we set the derivative equal to zero:
\[
e^{-x} (2x - x^2) = 0
\]
Since \( e^{-x} \) is never zero, we can solve:
\[
2x - x^2 = 0
\]
Factor the quadratic equation:
\[
x(2 - x) = 0
\]
So, \( x = 0 \) or \( x = 2 \).
Next, we check the second derivative to determine if \( x = 2 \) is a maximum. We take the second derivative of \( f(x) \):
\[
f''(x) = \frac{d}{dx}\left( e^{-x} (2x - x^2) \right)
\]
Using the product rule again:
\[
f''(x) = e^{-x} \left( 2 - 2x \right) - e^{-x} (2x - x^2)
\]
Simplify:
\[
f''(x) = e^{-x} \left( 2 - 4x + x^2 \right)
\]
Substituting \( x = 2 \) into this second derivative:
\[
f''(2) = e^{-2} \left( 2 - 4(2) + 2^2 \right) = e^{-2} \left( 2 - 8 + 4 \right) = e^{-2}(-2)
\]
Since \( f''(2)<0 \), we confirm that \( x = 2 \) is a maximum point.
Thus, the maximum of the function occurs at \( x = 1 \).