Solution (source code)

= Solution

The infinite walls impose $\psi(0)=\psi(L)=0$, and the interior time-independent <Schrödinger equation> is $\psi''+k^2\psi=0$ with $E=\hbar^2k^2/(2m)$. Its general solution is $A\sin kx+B\cos kx$. The first <boundary condition> gives $B=0$, and the second gives $kL=n\pi$. A nonzero normalizable state needs $n=1,2,\ldots$; $n=0$ would give the zero function.

<Wavefunction normalization>, $\int_0^L\sin^2(n\pi x/L)\,dx=L/2$, gives the <infinite square well> states and their <energy eigenvalues>:
$$
\boxed{\psi_n(x)=\sqrt{\frac2L}\sin\frac{n\pi x}L\quad(0<x<L),\qquad E_n=\frac{n^2\pi^2\hbar^2}{2mL^2}.}
$$
The <wavefunctions> vanish outside the well, and their full time dependence is $\psi_n(x)e^{-iE_nt/\hbar}$.