# Prove that function f has a local minima and maxima

$f:R->R, f(x) = (x^2+mx)e^-x$
Show that, for every m in R, the function f has a local minima and maxima.

First, I tried to find the derivative of the function f which is: $(e^{-x})(-x^2 + (2-m)x + m)$. After that, I tried to compute the critical points solving the ecuation $f'(x) = 0$. One critical point is infinity, and the other 2 critical points can be found solving the ecuation: $-x^2 + (2-m)x + m = 0$. Since the discriminant of that ecuation can't be negative, the solutions are: $x_1 =\frac{(-2 +m +\sqrt[]{m^2+2m+4})}{-2}$ and $x_2 = \frac{(-2 + m - \sqrt[]{(m^2+2m+4)}}{-2}$.

I don't know what to do from there since I have to compute the second derivative to find out the nature of the critical points and I'm not sure about the correctness of this solution.

$f'(x) = 0 \iff -x^2 + (2-m)x + m = 0$.
$\triangle = (2-m)^2 - 4\cdot (-1)\cdot m = 4 - 4m + m^2 + 4m = m^2 + 4 > 0$, $\forall m$. Thus $f'(x) = 0$ has two distinct real roots: $x_1$ and $x_2$, with $x_1 < x_2$. Using $1st$ derivative test, we see that:
$f'(x) < 0 \iff x < x_1$ or $x > x_2$
$f'(x) > 0 \iff x_1 < x < x_2$.
This shows $f(x)$ has a local min at $x_1$, and a local max at $x_2$.