When is maximising a definite integral the same as maximising the integrand? When is maximising
$$\int_a^b f(x) \text{d}x$$
the same as maximising $f(x)$?
Context: I was trying to find the most probable location of an electron in the ground state hydrogen atom, where the wavefunction is $\text{exp}(-r/a_0)$, and hence the probability density is $\text{exp}(-2r/a_0)$. The probability is therefore proportional to
$$\iiint e^{-\frac{2r}{a_0}}\text{d}^3{\bf r}.$$
Since in spherical coordinates, the volume of a spherical shell is $4\pi r^2 \text{d}r$, I am told that to maximise the probability, I should maximise $r^2 \text{exp}(-2r/a_0)$. However, I seem to be maximising the integrand, not the integral, here. If $\text{d}P \propto r^2 \text{exp}(-2r/a_0) \text{d}r$, is $\text{d}P/\text{d}r$ not just $r^2 \text{exp}(-2r/a_0)$?
 A: Read your problem carefully.  It is almost certainly asking for the maximum-probability value of the radial distance of the electron from the proton, rather than the most probable location of the electron.
What you are really doing, when you maximize $4\pi r^2 e^{-2r/a_0}$, is maximizing (over values of $r$) the integral of the probability function over the space in which the radial distance is the value $r$.  This tells you the most probable distance, which is something like $r = a_0$.  The most probable location, on the other hand, is at $r = 0$.
A: In order to make sense of this, maximizing an integral, we really need to introduce another parameter:
$$I(t)=\int_a^b f(t,x)\,dx$$
Now, clearly,
$$\max_t I(t)\le \int_a^b \max_t f(t,x)\,dx$$
We have equality when that $\max_t f(t,x)$ occurs at the same $t$ for all $x$. If we can maximize the function simultaneously for all $x$, then integrating that maximum gets us the maximum integral. If we can't, then we'll have to do something else.
For example, if that was $I(t)=\int_{-1}^1 tx\,dx$ for $-2\le t\le 2$, then the maximum of $f$ occurs at $t=2$ for $x>0$ and at $t=-2$ for $x<0$ - not the same place. The value of $I(t)$ is identically zero, while $\int_{-1}^1 \max_t(tx)\,dx=\int_{-1}^1 2|x|\,dx=2$.
Now, your "context"? That's really not the same thing - it's not about maximizing an integral. The "most probable location" should be the point at which the probability density is maximized (the origin). The "most probable distance", which seems to be what you actually want here, comes from transforming that spatial density function into a linear density function $f(r)=4\pi r^2\exp(-2r/a_0)$, the probability density for distance from the origin. And, again, we're just looking for where that density is largest.
A: Think of the definite integral as giving you the area under the curve of $f(x)$ above the interval $[a,b]$. Suppose at all values on the interval, you had another function $g$ which is always more than $f$ (i.e. $g(x)\geq f(x)$ for all $x\in [a,b]$). The area under $g$ is obviously greater. Therefore, when the integrand is bigger, the integral is bigger, and vice versa. (Note that you run into trouble here if on the interval $f$ is sometimes greater than $g$ and sometimes smaller than $g$, I'm assuming we don't need to care about this issue here.)
