Solution (source code)

= Solution

Interpret the box as an <infinite square well>, with zero potential on $0<x<a$ and impenetrable walls. The wavefunction vanishes at both walls. The time-independent <Schrödinger equation> inside is $-\hbar^2\psi''/(2m)=E\psi$. Multiplying by $\psi^*$ and <integration by parts> shows $E\int|\psi|^2dx=(\hbar^2/(2m))\int|\psi'|^2dx>0$ for any nonzero state with the wall conditions.

For $E>0$, put $k^2=2mE/\hbar^2$. The condition at zero gives $\psi=A\sin(kx)$, and the condition at $a$ requires $\sin(ka)=0$. The zero value of $k$ gives only the zero wavefunction, so the allowed <energy eigenvalues> are
$$
\boxed{E_n=\frac{\hbar^2\pi^2n^2}{2ma^2},\qquad n=1,2,3,\ldots.}
$$
The corresponding normalized <energy eigenstates> are $\sqrt{2/a}\sin(n\pi x/a)$. Each level is nondegenerate in this one-dimensional problem. A nonzero constant interior potential would add that constant to all energies.