# For what values of x is f(x)=x^2e^x concave or convex?

Jan 31, 2016

Concave: $\left(- 2 - \sqrt{2} , - 2 + \sqrt{2}\right)$
Convex: $\left(- \infty , - 2 - \sqrt{2}\right) \cup \left(- 2 + \sqrt{2} , + \infty\right)$

#### Explanation:

Concavity and convexity can be determined by the sign of the second derivative of a function:

• If $f ' ' \left(a\right) < 0$, then $f \left(x\right)$ is concave at $x = a$.
• If $f ' ' \left(a\right) > 0$, then $f \left(x\right)$ is convex at $x = a$.

Primarily, to find the first derivative, use the product rule.

$f \left(x\right) = {x}^{2} {e}^{x}$

$f ' \left(x\right) = 2 x {e}^{x} + {x}^{2} {e}^{x}$

Use the product rule again (twice!) to find the second derivative.

$f ' ' \left(x\right) = 2 {e}^{x} + 2 x {e}^{x} + 2 x {e}^{x} + {x}^{2} {e}^{x}$

$f ' ' \left(x\right) = {e}^{x} \left({x}^{2} + 4 x + 2\right)$

We must now find when $f ' ' \left(x\right)$ is positive and when it is negative. The sign could change from positive to negative or vice versa whenever $f ' ' \left(x\right) = 0$.

First, we can simplify finding when $f ' ' \left(x\right) = 0$ by recognizing that ${e}^{x}$ will never equal $0$, since it is always positive. Thus, we must only concern ourselves with the remaining part, ${x}^{2} + 4 x + 2$.

The sign of the second derivative could change when

${x}^{2} + 4 x + 2 = 0$

Use the quadratic equation or complete the square to find that the sign could change at

$x = - 2 - \sqrt{2} , - 2 + \sqrt{2}$

Thus, there are three intervals on which there is a distinct concavity, since we know the times when the concavity changes. The three intervals are $\left(- \infty , - 2 - \sqrt{2}\right) , \left(- 2 - \sqrt{2} , - 2 + \sqrt{2}\right) ,$ and $\left(- 2 + \sqrt{2} , + \infty\right)$.

We can use one test point from each interval to find the sign of the second derivative and, by extension, the concavity or convexity of each interval.

It may be helpful to note that $- 2 - \sqrt{2} \approx - 3.414$ and $- 2 + \sqrt{2} \approx - 0.586$.

mathbf[(-oo,-2-sqrt2)

Test point: $x = - 4$

$f ' ' \left(- 4\right) = {e}^{- 4} \left(16 - 16 + 2\right) = \frac{2}{e} ^ 4$

Since this is $> 0$, the interval $\left(- \infty , - 2 - \sqrt{2}\right)$ is convex.

mathbf[(-2-sqrt2,-2+sqrt2)

Test point: $x = - 1$

$f ' ' \left(- 1\right) = {e}^{- 1} \left(1 - 4 + 2\right) = - \frac{1}{e}$

Since this is $< 0$, the interval $\left(- 2 - \sqrt{2} , - 2 + \sqrt{2}\right)$ is concave.

mathbf[(-2+sqrt2,+oo)

Test point: $x = 0$

$f ' ' \left(0\right) = {e}^{0} \left(0 + 0 + 2\right) = 2$

Since this is $> 0$, the interval $\left(- 2 + \sqrt{2} , + \infty\right)$ is convex.

Note that convexity typically resembles $\cup$ on a graph and concavity more resembles $\cap$.

We can consult the graph of the original function:

graph{x^2e^x [-7, 2, -2, 4]}

The concavity does apparently shift twice, both in the $x = - 3$ish and $x = - \frac{1}{2}$ish areas.