A particle is in the ground state of an infinite square well with walls in the range x=[0,a]. At time t=0, the walls are removed suddenly and the particle becomes free. What is the energy of the free particle?
What I know: \begin{equation} \begin{split} V(x) &= 0, \; \; \; 0\le x \le L \\ &= \infty, \; \; \;otherwise \end{split} \end{equation} \begin{equation} \begin{split} \psi(x,0)&=\sqrt{\frac{2}{a}} sin(\frac{\pi x}{a}) \\ E_1 &= \frac{\pi^2 \hbar^2}{2ma^2} \end{split} \end{equation}
I've found the wave function in momentum space $\phi(k)$ by taking the Fourier transform of the initial wavefunction. \begin{equation} \begin{split} \phi(k) &= \frac{1}{2\pi\hbar} \int_{0}^{a} dx e^{ikx} \psi(x,0) \\ &=\frac{1}{a\pi\hbar} \frac{-\pi L (1+e^{-ikL)}}{k^2L^2 - \pi^2} \end{split} \end{equation}
I know $<E>=\frac{<p^2>}{2m}$, so I need to find \begin{equation} <p^2>= \int_{0}^{a} k^2 \mid \phi(k) \mid^2 dk \end{equation} Unfortunately, when I evaluate this integral, it diverges. Is there another way can I find energy of a free particle that yields an appropriate answer?
Note: I've also tried to evaluate the momentum space Schroedinger equation $i\hbar \frac{\partial \phi(p)}{\partial t} = H \phi(p)$. However, $\phi(p)$ is not time dependent from my evaluation, so the answer it yields is $0$.