Does this piecewise wave function work for a particle in the box? My prof gave us a particle in the box question,

particle in a box, $L=2$
$\Psi(x) = x$, for $x<1$
$\Psi(x) = 2-x$, for $x>1$
Find the energy expectation value.

and he said there is a problem and we need to explain it.
I setup my equation

$\frac{\hbar}{2m}\frac{\partial^2}{\partial x^2}\Psi(x) = E\Psi(x)$

I notice there is a hole in the function at $x = 1$. My understanding is there is no way for us to get the second derivative of this wave function, hence no way to find the energy expectation value. Is this sufficient? Even if having a hole is fine, the derivative of $x$ $\neq$ derivative of $2-x$ means the entire function is indifferentiable. Is this question this trivial?
 A: The problem is not that much that $\Psi$ is not differentiable in one point. Usually, we consider two functions which are equal almost everywhere (i.e. up to a set of measure 0) to be the same. A single point is a set of Lebesgue measure 0. Thus, that the derivative at a single point may be infinite is not a big problem. A function on $L^2(0,2)$ for which the derivative exists almost everywhere, is called weakly differentiable, and the space of all weakly differentiable $L^2$-functions on $(0,2)$ is the Sobolev space $H^1(0,2)$.
The actual problem of your example is much deeper. Let me start explaining this with the following observation: Let $P=-\mathrm{i}\partial_x$ be the momentum operator and $H=P^2 = -\partial_x^2$ the free Hamiltonian (I ignore constants like $\hbar$ and $m$ because they are irrelevant for this problem). You easily verify $H\Psi = 0$, $P\Psi(x) = -\mathrm{i}$ for $0<x<1$ and $P\Psi(x) = \mathrm{i}$ for $1<x<2$; hence, $\langle \Psi, H \Psi\rangle = 0$. However, $P$ is hermitian, therefore
$$\langle \Psi, H \Psi\rangle = \langle P\Psi, P\Psi\rangle = \int_0^2 |P\Psi(x)|^2 \mathrm{d}x = 2 \neq 0.$$
A contradiction!
To explain this apparent contradiction, let me state two mathematical facts:

*

*The momentum operator $P$ is an unbounded (i.e. not continuous) self-adjoint operator.

*Unbounded self-adjoint operators are not definable on the entire Hilbert space (Hellinger–Toeplitz theorem). The best we can hope for is that an unbounded self-adjoint operator is defined on a dense subspace.

Thus, an essential part of the definition of an unbounded operator is its domain (i.e. the vectors in the Hilbert space on which it is defined). A suitable domain for the momentum operator on the interval $(0,2)$ is the following domain with periodic boundary conditions:
$$D(P) = \{ \psi \in H^1(0,2) \mid \psi(0) = \psi(2) \}.$$
Accordingly, the natural domain of the Hamiltonian $H=P^2$ is
$$D(H) = D(P^2) = \{ \psi \in D(P) \mid P \psi \in D(P) \}.$$
In your example, $\Psi \in D(P)$ because $\Psi(0) = 0 = \Psi(2)$. However, the derivative $\Psi'$ is not an element of $D(P)$ because $\Psi'(0) = 1 \neq -1 = \Psi'(2)$. Thus, $\Psi$ is not an element of the domain of $H$. If $\psi \notin D(H)$, then the identity $\langle \psi, H\psi \rangle = \langle P\psi, P\psi\rangle$ is false in general. This resolves the above contradiction.
To summarise, the problem is that $\Psi$ and its derivative $\Psi'$ do not satisfy the same boundary condition.
