I have a question about momentum and energy of the infinite square well in quantum mechanics In Griffiths quantum mechanics, There is a problem that 

"Find the momentum-space wave function $\varphi(p,t)$ for the $n$th stationary state of the infinite square well."

The $n$th stationary state has only one energy value: $E= n^2h^2/(8mL^2)$. First, I thought that the momentum $p$ can only be $\pm \sqrt{2mE}$ because of $E=\frac{p^2}{2m}$. Second, I use de Broglie wavelength. In $n$th stationary state, $\lambda=2L/n$ and $p=h/\lambda$. So I thought $p$ only can be $\pm nh/2L$, and those are same with $\pm\sqrt{2mE}$.
But, It was wrong, If I use Fourier transforms to find the momentum-space wave function, $p$ can be every real numbers because $n$th stationary state is not eigenfunction of momentum! Why is it possible? I couldn't find physical reason of that. What is my fault in my first and second opinion?
In summary : When we measure energy, the possible number of the momentum is determined to be one(or two because of plus-minus), and when we measure the momentum, the possible number of the energy is infinite? What is my error?
 A: The key point is the boundary condition. 


*

*The momentum you got is the eigenvalue of momentum operator with the boundary condition that contains the information of potential that the particle experiences. This is a good quantum number. 

*When you do Fourier transformation using $e^{ipx}$ as your basis which corresponding to a free particle, the $p$ you have in $\psi(p,t)$ is the eigenvalue of the momentum operator without any constraints. This is not a good quantum number. So, simply speaking, what you are doing is expanding an eigenstate in a 'bad' basis $e^{ipx}$, and of course, all real $p$ will come into your expression. 
A: A particle in a potential, whatever it is, does not have a certain value of momentum. Mathematically the momentum operator does not commute with the potential, and physically the potential gradient is a force that changes the momentum. A Fourier transform of the Hamiltonian eigenstate is possible and it gives you a wave function different from a plane wave, it is natural.
The mean value of momentum is zero, but the mean of the square value is not zero.
