Heisenberg Uncertainty Principle Applied to an infinite square well I appreciate the statement of Heisenberg's Uncertainty Principle. However, I am a bit confused as to how exactly it applies to the quantum mechanical situation of an infinite square well.
I understand how to apply Schrödinger's equation and appreciate that energy Eigenvalues can be deduced to be
$$E_n=\frac{n^2\hbar^2\pi^2}{2mL^2}.$$
However, I have read somewhere that the reason that the quantum particle cannot have $n = 0$—in other words, $E = 0$—is because by having zero energy we also have a definite momentum with no uncertainty, and by the Heisenberg uncertainty principle this should lead to an infinite uncertainty in the position of the particle. However, this cannot the case be in an infinite well, as we know the particle should be somewhere in the box by definition. Therefore $n$ can only be greater than or equal to one.
Surely when $n = 1$ we have the energy as
$$E_1 = \frac{\hbar^2 \pi^2}{2mL^2},$$
which is also a known energy, and so why does this (as well as the other integer values of $n$) does not violate the uncertainty principle?
 A: Having definite energy and definite momentum are not the same thing.  The eigenstates of the Hamiltonian of the particle in a box have definite energy, but it turns out that they do not have definite momentum, and the spread in momenta is large enough to satisfy the Heisenberg uncertainty principle.

the reason that the quantum particle can not have n = 0 in other words E = 0 is because by having zero energy we also have a definite momentum with no uncertainty

No, the reason is the wavefunction $\psi(x)$ that you would get for $n = 0$ is identially zero everywhere, and so is not normalizable and does not lie in the Hilbert space of physically acceptable states.  $n = 0$ doesn't correspond to a particle with zero energy or momentum - it corresponds to the complete absence any particle at all.
A: This started off as comment, but right now I only have the reputation to answer. But this is by no means a rigorous answer.
There are a couple of assumptions your question makes that aren't strictly true. For a start, you seem to say that any definite value of energy would entail a definite value of momentum. This is true for a completely free particle, but this is no longer true for a particle that is undergoing some interaction (where is the interaction, you ask? Well the fact that it is placed in a box, of course!)
There's a simple and (in my opinion) instructive way to see this. If what you said were true, then the states of definite energy would also be the states of definite momentum. In other words, they would satisfy the eigenvalue equation $$\hat{p}\psi_n = p_n\psi_n$$ where $\hat{p}=\frac{\hbar}{i}\frac{d}{dx}$ is the momentum operator and $p_n$ is a constant (which would represent the measured momentum). Let us check if this is the case. The states of definite energy are given by
$$\psi_n = \sqrt{\frac{2}{L}}\sin\left(\frac{n\pi x}{L}\right)$$
The action of the momentum operator is thus
$$\hat{p}\psi_n = \frac{\hbar}{i} \sqrt{\frac{2}{L}} \frac{n\pi}{L} \cos\left( \frac{n\pi x}{L}\right) \neq p_n \psi_n$$
In other words, the states of definite energy are not states of definite momentum, since the momentum operator doesn’t yield the original wave function times a constant! Of course, you're right that the magnitude of the momentum would be fixed.
If you're still having trouble with this, here's a sloppy "intuitive" semi-classical example: say I gave you a (1-dimensional!) box with a particle (of unit mass) bumping around constantly inside it. I tell you that I measured the energy of this particle many times and it always came out to be exactly 8. Now I ask you to give me its momentum. "Aha!" you say, "when it is inside the box, there are no forces acting on it, and so the energy is simply given by:"
$$\frac{p^2}{2m} =\frac{p^2}{2} = 8$$
Thus, you find that the 'momentum' is 4! But wait a minute, you don't know if it's bouncing to the left or to the right. In other words, if it's $+4$ or $-4$! The fact that the particle interacts with the wall is responsible for its momentum 'flipping' sign. 
In the same way, for the particle in the box, the magnitude of the momentum $|p|$ is given by
$$|p| = \pm \sqrt{2mE}$$ 
So what's the uncertainty in $p$? Well, it's simply $\Delta p = +|p| - (-|p|) = 2|p| = \frac{2 n\pi \hbar}{L}$. What about the uncertainty in $x$? Well, it could be anywhere in the box, and so $\Delta x = L$, the box's length.
Let us try to find 
$$\Delta x \Delta p = 2n\pi \hbar > \frac{\hbar}{2}$$ for all values of $n\geq 1$.
Clearly, when $n=0$ this no longer works. We can understand this in many ways. A simple way would be to realise that when $n=0$, the magnitude of the momentum is $0$, and thus there are no 'positive' and 'negative' values it could take: it most definitely has a momentum of exactly zero, with no uncertainty. This would be allowed, if you were not in a box. However, placing yourself in a box, meaning that $\Delta x < \infty$, means that you necessarily have a minimal non-zero momentum, using the argument you mentioned earlier.
Moreover, the mathematics tells you that a state with $n = 0$ is the trivial state $\psi_0(x) = 0$. The mod-square integral of this function is 0, which can be interpreted as such a particle simply not existing.
A: In addition to the comment of @tparker stating that $n=0$ corresponds to $\psi(x)=0$, please note (using $L=1$):


*

*There is no uncertainty relation between $E$ and $p$, i.e. there is no equation of the type $\Delta E\Delta p=$(something),

*On the other hand, one can deduce, for the ground state ($n=1$) of the infinite well that
$$
(\Delta x)^2=\frac{\pi^2-6}{12\pi^2}\, ,\qquad (\Delta p^2)=\hbar^2 \pi^2=2mE_1
$$
so there is no problem with $\Delta p\Delta x\ge \frac{\hbar}{2}$.  In addition, since $\psi_n(x)$ is an eigenstate of $\hat H$, it follows that $\Delta E=0$ for those states.

*Calculating $\Delta E$ for the infinite well can be deceitful.  This is because $\hat p^2$, which is required to compute moments of $\hat H$, is not self-adjoint.  Basically, powers of $\hat p^2$ can take "valid" wave functions (which satisfy the boundary conditions of the problem and other criteria to be legitimate wave functions) and transform them into "illegal" wave functions.  The simplest example is to consider the wavefunction 
$$
\psi(x)=\sqrt{30}x(x-1)\, .
$$
It is $0$ at $x=0$ and $x=1$, and normalized so satisfies the boundary conditions to be a legitimate wave function (albeit not an eigenstate of $\hat H$.)  If $\hat H$ were self-adjoint, then $\hat H^2$ would also naively also be self-adjoint, but $\hat H^2\psi(x)=0$, which no longer satisfies the boundary conditions. 


This enters into the evaluation of $\Delta E$ as follows.  Defining $\phi(x)=\hat p^2\psi(x)=-2\sqrt{30}\hbar^2$ one easily verifies that, in the calculation of $\langle E^2\rangle$ required to obtain $(\Delta E)^2$, that $H^2\psi(x)\sim p^4\psi(x)=\hbar^4 d\psi(x)/dx^4=0$ but
$$
\int_0^1 dx \psi(x) \left[p^4 \psi(x)\right]\ne \int_0^1 \phi(x)\phi(x)\ne 0\, .
$$
In other words:
$$
\langle \hat H\psi\vert \hat H\psi\rangle \ne \langle \psi \vert \hat H^2\psi\rangle
$$
so calculating $\Delta E$ for finite square wells can be problematic if one is not very careful.
This is an instructive example of a situation where "self-adjoint" is NOT the same as hermitian.
This paper provides lots of details of issues with the finite well.
(I apologize in advance to my colleagues with background in functional analysis for such as "loose" argument that $\hat p^2$ is not self-adjoint.) 
A: This question is actually almost identical to a question I had in my first year quantum mechanics course. It posed that a hypothetical friend asked you why having definite energy in the infinite potential well doesn't violate the uncertainty principle. Here I will provide you with the answer I gave all those years ago.
Consider an energy above $E=0$. Then the momentum of the state must satisfy $E=p^2/2m$. Now, there are two solutions for $p$, corresponding to a positive and negative momentum. The uncertainty can thus be calculated as
$$\Delta p^2=\langle p^2\rangle-\langle p\rangle^2=2mE=\frac{n^2\hbar^2\pi^2}{L^2}$$
Clearly, for $n=0$ the uncertainty vanishes, but is perfectly finite for all other values. Thus, so long as $\Delta x^2$ is large enough (it is), the uncertainty principle is perfectly satisfied for all $n>0$.
Another reason that the $n=0$ state is unphysical is because it is not normalisable. Indeed, the $n=0$ state would have to satisfy
$$\frac{\mathrm{d}^2\psi}{\mathrm{d}x^2}=0$$
And thus is linear. However, there is no nonzero linear function that can satisfy the necessary boundary conditions. Thus, $\psi=0$ everywhere and is not a physical state in our Hilbert space.
I hope this helped!
A: Provided that we have an infinite square well with potential
$$
V(x)=\begin{cases}
0, \text{ if }0<x<L,\\
+\infty, \text{ otherwise}
\end{cases}
$$
we obtain the wave functions as
$$
\psi_n(x)=\sqrt{\frac{2}{L}}\sin\left(\frac{\pi n x}{L}\right),
$$
where $n$ is a positive integer.
it is now straightforward to calculate the necessary averages (using the trigonometric formulae for double angle and the integration by parts):
$$
\langle n |\hat{p}|n\rangle=\int_0^L\psi_n(x)\hat{p}\psi_n(x)dx=0,\\
\langle n |\hat{p}^2|n\rangle=\int_0^L\psi_n(x)\hat{p}^2\psi_n(x)dx=\frac{\hbar^2\pi^2n^2}{L^2},\\
\langle n |\hat{x}|n\rangle=\int_0^Lx\psi_n^2(x)dx=\frac{L}{2},\\
\langle n |\hat{x}^2|n\rangle=\int_0^Lx^2\psi_n^2(x)dx=L^2\left(\frac{1}{12}-\frac{1}{2\pi^2n^2}\right).
$$
We can now evaluate the standard deviations of momentum and position as
$$
\sigma_p=\sqrt{\langle n |\hat{p}^2|n\rangle - \langle n |\hat{p}|n\rangle^2}=\frac{\hbar \pi n}{L},\\
\sigma_x=\sqrt{\langle n |\hat{x}^2|n\rangle - \langle n |\hat{x}|n\rangle^2}=L\sqrt{\frac{1}{12}-\frac{1}{2\pi^2n^2}}
$$
Thus, we have
$$
\sigma_x\sigma_p=\hbar\pi n\sqrt{\frac{1}{12}-\frac{1}{2\pi^2n^2}}
=\frac{\hbar}{2}\sqrt{\frac{6\pi^2n^2-1}{3}}
$$
Since $\pi^2\approx 10$, for the ground state ($n=1$) we have
$$
\sigma_x\sigma_p\approx\frac{\hbar}{2}\sqrt{\frac{59}{3}}>\frac{\hbar}{2}.
$$
For higher $n$ the inequality is even stronger. However, if we took $n=0$, we would have a nonsense imaginary answer (of course, the wave function is identically zero for $n=0$).
