Solution (source code)

= Solution

Inside the <particle in a box>, the <Quantum Hamiltonian> is
$$
\boxed{\hat H=-\frac{\hbar^2}{2m}\frac{d^2}{dx^2},\qquad 0<x<a.}
$$
The infinite potential outside imposes the <Dirichlet boundary conditions> $\psi(0)=\psi(a)=0$ and a zero <wavefunction> outside the interval. These boundary conditions are part of the <Hamiltonian operator>, rather than an optional addition.