Uncertainty in momentum of an excited electron trapped in a box (1D)? An electron is trapped in a one-dimensional well of width $0.132\,$nm. The electron is in the ninth excited state ($n=10$) state. What is the uncertainty in its momentum? The problem gives a hint to use the equation $\Delta{p_x}=\sqrt{(p_x^2)_{avg}}$ (the root mean square of the momentum of the particle). I know the wavefunction of the electron is this:
$$\psi(x)=\sqrt{\frac{2}{L}}\sin\left(\frac{10\pi}{L}x\right)$$
But since the probability density function is a function of position, and not momentum, how do I calculate the RMS of the momentum from this?
 A: Let's start with what I think you already know: first, that the root mean square of a finite set of values $p_i$, each of which occurs $n_i$ times, is given by
$$p_\text{RMS}^2 = \frac{\sum_{i=1}^N n_i p_i^2}{\sum_{i=1}^N n_i}$$
This makes sense, right? It's just the average of the squares of the elements, weighted by the number of times each element occurs. (And then you take the square root at the end, but I wrote the formula for $p_\text{RMS}^2$ to avoid an ugly square root sign.)
It should also make sense that this can be written
$$p_\text{RMS}^2 = \sum_{i=1}^N P_i p_i^2$$
where $P_i = \frac{n_i}{\sum_{i=1}^N n_i}$ is the probability of getting $p_i$ when you pick an $p$ out of the full set. Then this generalizes straightforwardly to an infinite set: if you have a continuous probability distribution over possible values of $p$, then the RMS momentum is
$$p_\text{RMS}^2 = \int P(p) p^2\mathrm{d}p\tag{1}$$
So the problem really reduces to finding the probability distribution $P(p)$ from the given wavefunction. (This concludes the "what you know" section.)
There are basically three ways to do this. The conceptually straightforward one is to compute the momentum-space wavefunction, as the Fourier transform of the position-space wavefunction,
$$\phi(p) = \frac{1}{\sqrt{2\pi\hbar}}\int\psi(x)e^{-ipx/\hbar}\mathrm{d}x$$
and then compute the probability from the momentum-space wavefunction just as you would do it with position:
$$P(p) = \lvert\phi(p)\rvert^2\tag{2}$$
The second way, which is kind of just a shortcut to the first way, is to notice that this particular wavefunction is a linear combination of a small number of momentum eigenstates. That means it only has contributions from a small, finite number of different values of momentum, i.e. the momentum eigenvalues. You can compute the RMS of those few momentum eigenvalues using the formula for RMS of a discrete set of numbers. Note that, unlike the other two methods, this one doesn't work for an arbitrary wavefunction. It only works when your wavefunction is the sum of a small number of momentum eigenstates.
The third way is by using quantum-mechanical machinery, i.e. operators. To see how this works, go back to equation (1), and note that in combination with equation (2), you can write it as
$$p_\text{RMS}^2 = \int\lvert\phi(p)\rvert^2 p^2\mathrm{d}p = \int\phi^*(p)p^2\phi(p)\mathrm{d}p\tag{3}$$
The process of quantization entails replacing values (of momentum, $p$) with operators ($\hat{p}$) in certain places, which converts this into
$$p_\text{RMS}^2 = \int\phi^*(p)\hat{p}^2\phi(p)\mathrm{d}p\tag{4}$$
I'm not giving any justification here that this is how the quantization should be done - perhaps you've learned this elsewhere - but it should seem reasonable that equation (4) is a plausible generalization of equation (3), given that the momentum operator $\hat{p}$ acting on a function of momentum $\phi(p)$ just means "multiply that function by $p$."
The advantage of this approach is that you don't have to work with functions of momentum only. You can write the same equation in position space,
$$p_\text{RMS}^2 = \int\psi^*(x)\hat{p}^2\psi(x)\mathrm{d}x$$
as long as you can characterize how the momentum operator $\hat{p}$ acts on a function of position $\psi(x)$. In fact, this is well known:
$$\hat{p} = -i\hbar\frac{\partial}{\partial x}$$
(Again, I'm not justifying either of the last two equations here.) So substituting that in, you get
$$p_\text{RMS}^2 = -\hbar^2\int\psi^*(x)\frac{\partial^2}{\partial x^2}\psi(x)\mathrm{d}x$$

Incidentally, I would note that the RMS momentum does not actually give the momentum uncertainty of the wavefunction. So technically, the hint you were given may not be correct. The momentum uncertainty $\sigma_p$ is defined as the standard deviation, which you can get from
$$\sigma_p^2 = \int P(p)(p - \bar{p})^2\mathrm{d}p$$
where $\bar{p}$ is the mean (average) momentum. Only when $\bar{p} = 0$ does the RMS momentum match the uncertainty. For your particular case, you can check whether that holds true, and thus whether the hint is right or not.
