Maximizing an exponential function The function goes like the following:
$$f(r) = \frac {r^2e^{-r/a}\sin^2\theta e^{2i\phi}}{64\pi a^5}$$
I tried to use some tools of calculus, but all seem to bring me a wrong answer.
I want to maximize the value of $f(r)$ and know the value of $r>0$ that maximizes $f(r)$. What would be the way? 
 A: First, you can't really maximize this function, since it's complex and the complex numbers aren't ordered. I suspect you want to maximize its absolute value.
You can drop all the complicated factors that don't contain $r$, so the basic problem is to maximize $r^2\mathrm e^{-r/a}$. This you can do by setting the derivative zero:
$$
\frac{\mathrm d}{\mathrm dr}\left(r^2\mathrm e^{-r/a}\right)=2r\mathrm e^{-r/a}-\frac1ar^2\mathrm e^{-r/a}=\left(2r-\frac{r^2}a\right)\mathrm e^{-r/a}=r\left(2-\frac{r}a\right)\mathrm e^{-r/a}\stackrel{!}{=}0\;.
$$
This is fulfilled when any of the factors is $0$. The maximum you want is at $2=r/a$, and thus $r=2a$.
A: It is hard to know what you mean by maximize, since in general your expression is a complex non-real number, and maximization has no meaning. 
But if we treat the question as one of maximizing $Kr^2e^{-r/a}$, where $K$ and $a$ are positive constants, then the usual calculus tools work. The derivative is 
$$-K\frac{r^2}{a}e^{-r/a}+2Kre^{-r/a}.$$
This is $0$ at $r=0$ (irrelevant) and at $r=2a$. That gives the maximum. 
A: When you take the derivative and make it equal to zero you have the following equation
$$e^{-r/a}(2r-\frac{r^2}{a})=0$$
then you have roots $r_0=0$, $r_1=\infty$, $r=2a$
