Do wave functions really belong to $L^2$ space, or do we need to restrict our physical Hilbert space even further? I am beginning to study quantum mechanics and I got stuck right at the beginning. 
I am trying to prove that the time derivative of the expected value of momentum of a particle is the (negative) expected value of the gradient of the potential, i.e., in one dimension we have
\begin{equation}
\frac{d\langle p\rangle}{dt}=-\left<\frac{dV}{dx}\right>
\end{equation}
which means
\begin{equation}
\frac{d\langle p\rangle}{dt}=-\int_{-\infty}^{\infty}\psi^*\frac{\partial V}{\partial x}\psi\ dx
\end{equation}
(here $\psi^*$ is the complex conjugate of $\psi$)
The wavefunction $\psi$ should be square summable, i.e. living in $L^2(\mathbb{R})$. I understand that we can quotient this space with the equivalence relation that associates two functions that are equal almost everywhere, so we can correctly state that $\psi(x,t)\longrightarrow 0$ when $x\longrightarrow\pm\infty$ and in this way we can get rid of the boundary terms when integrating by parts. But in the derivation of the above relation I got the following:
\begin{equation}
\frac{d\langle p\rangle}{dt}=
\int_{-\infty}^\infty V\left(\psi^*\frac{\partial\psi}{\partial x}+\psi\frac{\partial\psi}{\partial x}^*\right)\ dx
-\frac{\hbar^2}{2m}\left[\frac{\partial\psi}{\partial x}^*\frac{\partial\psi}{\partial x}\right]_{-\infty}^{\infty}
\end{equation}
Now, the boundary term should vanish for the relation to be verified, but why does it vanish? There are functions in $L^2$ whose derivatives are not in $L^2$, and that boundary term does not vanish in some of those cases. Should we be considering wave functions in some kind of Sobolev space instead? Is there a physical reason behind the vanishing of the boundary terms?
 A: You're right that one technically has to be careful and Sobolev spaces etc. or some subset of $L^2$ with appropriate boundary conditions should be considered when one wants to be precise. 
In introductory texts on quantum mechanics, however, these details concerning boundary terms are usually (succesfully) shoved under the rug by saying things like "the field and its derivatives fall off to zero near infinity". This approach allows one to focus more on the physics and less on the mathematical side of things. Of course, it's all just a matter of taste, as long as you get the right results ;-)
Vanishing of the wave function and its derivatives near infinity is typically motivated by stating that the system under consideration is somehow localized in space, and invoking the seemingly reasonable principle that this should not influence the physics far away: In mathematical terms, one assumes that all these fields have compact support.
From my personal experience with rigorous quantum mechanics, one typically ends up obtaining exactly the same results that one derives by more elementary---and to some, less satisfactory---means in "physical" QM. 
