# Find the value of $x$ that maximizes $f(x) = a^2 \operatorname{exp}\Big[\frac{x}{a^2}-\frac{x^2}{2a^2}\Big]$

Let $a$ be a positive real constant and let $x>0$. I want to find $x$ such that the function $f:(0,\infty) \rightarrow \mathbb{R}$ defined by

$$f(x) = a^2 \operatorname{exp}\Big[\frac{x}{a^2}-\frac{x^2}{2a^2}\Big]$$

is maximized.

Taking the first derivative with respect to $x$, I get

$$f^{\prime}(x) = (1-x)\operatorname{exp}\Big[\frac{x}{a^2}-\frac{x^2}{2a^2}\Big]$$

Setting $f^{\prime}(x) = 0$ and solving for $x$, I get $x = 1$ since $\operatorname{exp}\Big[\frac{x}{a^2}-\frac{x^2}{2a^2}\Big]$ is positive for all real $x$.

To use the first derivative, I observed that for all $x \in (0,1)$, we have $f^{\prime}(x) > 0$; and for all $x>1$, we have $f^{\prime}(x) < 0$. Thus $x=1$ maximizes $f$.

How does this look?

you can find the maximum value of $$x-\frac{x^2}{2}$$