Consider the Hilbert space $H$ of square-integrable complex functions on the real line equipped with the inner product $$\langle \phi,\psi\rangle:=\int \phi^*\psi d\mu,$$ where $\mu$ is the Lebesgue measure and $*$ denotes complex conjugation. For a given $\psi\in H$, with $\|\psi\| := \sqrt{\langle \psi, \psi\rangle} = 1$, define the expectation value $\langle Q \rangle$ of an operator $\hat{Q}$ on $H$ as $\langle Q \rangle:=\int \psi^* \hat Q\psi d\mu$.
Clearly, the function $\psi(x) = e^{-|x|}$ is in $H$ and the momentum operator $\hat{p}:=-i\frac{d}{dx}$ is a symmetric operator on (a subset of) $H$. The computation for $\langle p^2 \rangle$ is as follows:
\begin{align*} \langle p^2 \rangle &= \int_{-\infty}^\infty e^{- |x|} \left(-\frac{d^2}{dx^2}\right)e^{- |x|} dx\\ &= -\int_{-\infty}^\infty e^{- |x|} \frac{d^2}{dx^2}e^{- |x|} dx = -\left(\int_{-\infty}^0 e^{ x} \frac{d^2}{dx^2}e^{ x} dx + \int^\infty_0 e^{- x} \frac{d^2}{dx^2}e^{- x} dx\right)\\ &= -\left(\int_{-\infty}^0 e^{2 x} dx + \int^\infty_0 e^{-2 x} dx\right) = -2 \int^\infty_0 e^{-2\alpha x} dx = -1. \end{align*}
Which I find strange because by symmetry we should have $\langle p^2\rangle = \langle \psi,\hat p^2\psi\rangle = \langle \hat p\psi,\hat p\psi\rangle\geq0$. I have tried to figure out what might be the problem and have come to the following conclusions:
$\psi$ is not differentiable at $x=0$, but that should not be an issue under the integral sign since $\{0\}$ is a set of measure zero.
My computation is wrong and have checked it numerous times.
Please help.
The domain of the differentiation operator is the space of all complex-valued functions $f$ absolutely continuous on $\Bbb{R}$ such that $f\in L^2(\Bbb{R})$ and $f'\in L^2(\Bbb{R})$ where $f'$ is the derivative a.e. of $f$.
The function $\psi(x)=\exp(-|x|)$ meets these conditions, so $\psi$ is in the domain of the differentiation operator.
But what is $\psi'$? $\psi'(x)=-\exp(-x)$ for $x>0$ and $\psi'(x)=\exp(x)$ for $x<0$. So $\psi'$ is discontinuous at $0$. The right limit value at zero is $-1$ while the left limit value at zero is $1$. Hence $\psi'$ is not in the domain of the differentiation operator. $\hat{p}^2\psi$ is undefined.
You can still compute $\langle\hat{p}\psi,\hat{p}\psi\rangle$ because $\hat{p}\psi\in L^2(\Bbb{R})$. But this isn't equal to $\langle\psi,\hat{p}^2\psi\rangle$. The latter value is undefined.
Edit: An informal way to view this is that the second derivative $\psi''$ is a sum of a multiple of a delta-function with a function smooth on $\Bbb{R}\setminus\{0\}$. Since a delta-function is not a member of $L^2(\Bbb{R})$, neither is $\psi''$.