When solving the Schrodinger equation in case of finite potential well, we get the following equations after separation: $$(1)-\frac{\hbar^2}{2 m} \frac{d^2 \psi_1}{d x^2} = ( E_1 - V_o) \psi_1$$ $$(2)-\frac{\hbar^2}{2 m} \frac{d^2 \psi_2}{d x^2} = E_2 \psi_2 $$ $$(3)-\frac{\hbar^2}{2 m} \frac{d^2 \psi_3}{d x^2} = ( E_3 - V_o) \psi_3$$
I was wondering why all of $E_1$, $E_2$, $E_3$ should be equal. Using the argument for energy, I get that they should. But mathematically they pose no problem whatsoever as solutions to the equation. Moreover, if I use the fact that the second order derivative of $\psi$ should exist (which I haven't seen anyone else doing), I get the additional relation that $E_1 = E_3$ and $V = E_1 - E_2$. I know this looks absurd when viewed in terms of energy, but why isn't this actually valid?
Edit:
This is what I'm saying should be done:
$\psi = \begin{cases} \psi_1, & \mbox{if }x<0\mbox{ (the region outside the box)} \\ \psi_2, & \mbox{if }0<x<L\mbox{ (the region inside the box)} \\ \psi_3 & \mbox{if }x>L\mbox{ (the region outside the box)} \end{cases}$
where $\psi_1 = Ae^{\alpha x}$, $\psi_2 = Csin(kx) + Acos(kx)$, $\psi_3 = Fe^{- \alpha x}$, along with some relation between $A$, $C$, $D$, and $F$ after continuity of $\psi$ and $\frac{\partial \psi}{\partial x}$.
Now if we impose existence of $\frac{\partial^2 \psi}{\partial x^2}$, for the first and second regions we have $LHD( \frac{\partial \psi}{\partial x} ) = RHD( \frac{\partial \psi}{\partial x} )$ (left and right hand derivative). Now substituting values from the Schrodinger equation, we have
$( E_1 - V_o) \psi_1 \mid_{x=0} = E_2 \psi_2 \mid_{x=0} \implies E_1 - V_o = E_2$ (since $\psi_1 \mid_{x=0} = \psi_2 \mid_{x=0}$). So we get $E_1 - E_2 = V_o$. Similarly from second and third region we get $E_3 - E_2 = V_o$ and hence $E_1=E_2$.