Momentum of particle in a box Take a unit box, the energy eigenfunctions are $\sin(n\pi x)$ (ignoring normalization constant) inside the box and 0 outside. I have read that there is no momentum operator for a particle in a box, since $\frac{\hbar}{i}\frac{d}{dx}\sin(n\pi x)=\frac{\hbar}{i}n\pi\cos(n\pi x)$ and this isn't 0 at the end points. Nonetheless, we can write $\sin(n\pi x)=\frac{e^{in\pi x}-e^{-in\pi x}}{2i}$, which seems to imply that there are two possible values of momentum: $n\pi$ and $-n\pi$, each with 50% probability.. Is this wrong? If you measured one of these momenta and the wavefunction collapsed to one of the eigenstates then it wouldn't solve the boundary conditions. So, what values of momentum could you obtain if you measured the momentum of a particle in a box?
Edit: I know that you can't measure the momentum of a particle exactly, but normally after a measurement of momentum, or such a continuous observable, the wavefunction collapses to a continuous superposition of momentum eigenstates corresponding to the precision of your measurement. But in this case since the wavefunction seems to just be a superposition of two momentum eigenstates, the wavefunction must have to collapse to one of them exactly, or so it seems.
 A: There are two different issues. One of them is the sign of the momentum; the other one is whether the momentum is spread (it's not because of the unnatural boundary conditions).
Concerning the first point, the standing wave (sine) is a real function and every real wave function has the same probability to carry momentum $+p$ and $-p$. So indeed, both of them are equally likely.
But even if you write the sine as a difference of two complex exponentials, it's still true that these exponentials aren't equal to the wave function everywhere – just inside the box – so it's still untrue that the momentum is sharply confined to two values $p$ and $-p$.
To get the probabilities of different momenta, you need to Fourier transform the standing wave – a few waves of the sine. One has
$$\int_0^1 dx\,\sin(n\pi x)\exp(ipx) = \frac{n\pi[-1 +e^{ip}(-1)^n]}{p^2-n^2\pi^2} $$
Square the absolute value to get the probability density that the momentum is $p$. The momentum $p$ should have the natural prefactors $\hbar/L$ etc. and the overall wave function should get another normalization factor for the overall probability to equal one. This changes nothing about the shape of the probability distribution: almost all values of $p$ have a nonzero probability.
A: I think this is a great question. http://arxiv.org/abs/quant-ph/0103153 This article explains why we shouldn't enforce the boundary conditions that we do (the wavefunction goes to 0 at the boundaries) and instead should use the condition that the wavefunction is equal at both end points. The justification is partly for mathematical reasons, but partly because that condition is too strong physically; the wavefunction isn't measurable. On the other hand the probability of finding the particle between a and b is measurable. We just want to make sure that if a=0 and b approaches 0 that the probability approach 0 continuously. This is achievable even if the wavefunction is discontinuous. 
Once we enforce the weaker condition, certain functions that are exponentials inside the box and zero outside are allowed (the ones with the same wavelengths as the energy eigenstates) and these are in fact the momentum eigenvalues. So exactly as you said, if you measure the momentum, the particle will collapse into one of those states. 
A: I'd like to elaborate on @Lubos Motl's response. 
The assumption that the wave function must go to zero is modeled as a sine function. This is tricky because, as stated above, the wave function used does not go to 0 everywhere outside the box. This is a subtlety that's never discussed in courses because it opens a Pandora's box about how valid this approximation is (which it is an adequate model for doing calculations, see http://arxiv.org/abs/0704.1820). One possible, yet cumbersome, solution, as seen in the Fourier integral in the post above, would be to have the wave function in the form of 
$$ \psi= \theta(x)\theta(1-x)\sin(n\pi x),$$
where $\theta(x)$ is the Heaviside step function. This effectively cuts off the wave function from existing beyond the boundary. 
Additionally, momentum, in this case, is not a "good" quantum number. This means that because you do not have a periodic, infinite, system, the wave function cannot take on any value of momentum. The $n\pi$ are harmonics that this model allows for due to the boundaries. This is just a model and may not depict the exact results in systems that are described.
