Solution (source code)

= Solution

Within the well, the potential is zero and the <Hamiltonian (quantum mechanics)> is purely kinetic:
$$
\boxed{\hat H=-\frac{\hbar^2}{2m}\frac{\mathrm d^2}{\mathrm dx^2}.}
$$
The infinite walls are encoded in the operator's boundary conditions $\Psi(0)=\Psi(a)=0$, rather than differentiated as part of the interior expression. Since
$$
\Psi_n''(x)=-\left(\frac{n\pi}{a}\right)^2\Psi_n(x),
$$
we obtain
$$
\hat H\Psi_n=\boxed{\frac{n^2\pi^2\hbar^2}{2ma^2}}\Psi_n,
\qquad \boxed{E_n=\frac{n^2h^2}{8ma^2}}.
$$
These positive <energy eigenvalues> grow quadratically with the <quantum number>; the <ground state> has a nonzero confinement energy.