A Quora question asks: “The wave function is contained in a Hilbert space while its basis vectors aren’t because plane waves are not square-integrable functions. Is this true for all Hilbert spaces or only for the square-integrable sub-space?”
My response: There are a number of ways you are misusing the language here, and I thought at first that your main misunderstanding may be to think that an element of a Hilbert space has its own set of basis vectors – while in quantum theories the choice of a relevant basis is more often related to an observable than to a state. But perhaps you are not associating the “basis” with a particular wave function, and rather thinking of it as associated with the position space representation as a whole. That makes more sense so let’s go back and try to describe the situation more clearly.
A wave function is a representation of an element of the Hilbert space of quantum states by a square integrable function (but the space of such functions is actually isomorphic to the entire state space as a whole and not just a proper sub-space). There are many such representations, sometimes with associated ways of identifying bases and sometimes not. In particular for any observable with purely discrete spectrum (such as the Hamiltonian of a harmonic oscillator) there is a basis of eigenvectors, and every state is represented by a square summable sequence corresponding to its spectral decomposition. Unfortunately the position and momentum observables have pure continuous spectrum and no eigenvectors, so the corresponding representations involve elements from some larger space. The usual “position space” wave function corresponds to the spectral decomposition of the position operator, and the analogue of basis vectors are actually not functions at all but rather distributions (in particular delta functions). The plane waves on the other hand are (position-space representations of) eigenfunctions of the momentum operator (but again not eigenvectors since not in the Hilbert space).
So in the end I might answer your question by saying that there is only one Hilbert space of states but that any complete set of observables can be used to represent it in terms of square integrable functions (or sequences); and that it is only in the case of pure point spectrum that the resulting spectral decomposition can be described in terms of an actual basis, while observables with continuous spectrum generally require some kind of generalized basis involving functions or distributions that do not actually correspond to normalizable states.