I'm having trouble understanding the legitimacy of solving the Schrödinger equation for a particle confined in an infinite square well. Aren't we supposed to solve it for the whole space and not just some region before we claim it to be the state of the particle?
Also what about the energy eigenvalues obtained this way? If we solve the eigenvalue equation $\hat E\psi=E\psi$ over a subset of whole space and obtain energy eigenvalues, what would guarantee that these eigenvalues are what one would get when one solves the energy eigenvalue equation over whole space?
Another trouble is for $x>L$ or for $x<0$ (the well is $0<x<L$), the energy eigenvalue equation would look something like $$-\frac{\hbar^2}{2m}\frac{d^2\psi}{ dx^2}+V(x)\psi=E\psi\implies0+(\infty)(0)=(E)(0) $$ this equation looks horrendous to me given $E$'s are some finite numbers. What about the well boundaries $x=0$ and $x=L$, how do we know wavefunction would be continuous here?