Does the wavefunction need to be continuous and satisfy other boundary conditions? So, please don't ignore this question thinking it's a duplicate or something. I have read all the answers on StackExchange and in other articles, but either the math is too confusing, or the answers don't make sense.
So, I have a first course in Quantum Mechanics, and I am mostly following Griffiths for problems and theory. So, while reading about the infinite square well, I concluded that the reason why the energies in such problems (or say any problem with the Energy eigenfunctions equation/TISE) are quantized is because of the boundary continuity and normalizability. Because the energy eigenfunctions need to be continuous, we only take sine waves which start and end at 0 at the interface of the well, and that's why only specific energies are allowed.
But in one of the problems, he gives an unreasonably discontinuous function which doesn't even go to zero at the boundary as the initial wavefunction and mentions in a footnote, and I'm directly quoting from Problem 2.8, D.J. Griffiths, Introduction to QM, 2nd edition. -

A particle of mass $m$ in an infinite square well starts out in the left half of the well and is at $t=0$ equally likely to be found at any point in that region.
There is no restriction on the shape of the starting wave function as long as it is normalizable. In particular, $\psi(x,0)$ need not have a continuous derivative, in fact, $\psi(x,0)$ doesn't even have to be a continuous function.

Now if this is true about $t=0$, shouldn't this be true for any time? What is so special about $t=0$? But if the wavefunction doesn't need to be continuous, then our entire analysis of the infinite well energy eigenstates with quantized energies doesn't make any sense. So what are the conditions on a physical wavefunction and why do they exist?
 A: There are several issues involved here:


*

*The wave functions should be continuous and satisfy the boundary conditions. This can be grounded in physical principles, but it is also obvious from the Schrödinger equation, which implies that a wave function has a time derivative and the first and the second derivatives in space.

*When solving physical problems we often do approximations or assume limiting cases, which make the problem at hand easier to solve mathematically. This, btw, is the case of the infinite square well - solving for the energy levels of a finite well is a lot more challenging. Square well itself is an approximation to more realistic smoother shapes. Another frequently used case is a barrier or well modeled by a delta-function - this leads to the discontinuity of the second derivative of the wave function.

*The first part of your question has to do with the eigenfunctions in the infinite square well, whereas the second with a time dependent evolution of a wave function. The latter is not an eigenfunction, but can be expanded in them, which is the point of the problem, and can be done. The problem is badly posed and you were right to question it, but, after all, it is just an exercise problem, not real scientific research.

