# Ambiguity in number of basis vectors [duplicate]

The dimension of the Hilbert space is determined by the number of independent basis vectors. There is a infinite discrete energy eigenbasis $\{|n\rangle\}$ in the problem of particle in a box which can be used to expand a general state $|\psi\rangle$ as: $$|\psi\rangle=\sum\limits_{n=0}^{\infty} C_n |n\rangle$$ Here, the basis implies that the Hilbert space has countably infinite number of basis vectors. But one could well expand $|\psi\rangle$ in any other basis as well, say the continuous position basis. Then that superposition, $$|\psi\rangle=\int dx \psi(x)|x\rangle$$ is also possible. But this basis $\{|x\rangle\}$ is continuous and uncountably infinite. Such sets cannot be equal because they have different cardinality. Then my questions is how many independent basis vectors are really there in this Hilbert space?

The answer is that $\{|x\rangle\}$ is not a basis of $L^2(\mathbb R)$ which admits only countable basis. The point is that objects like $|x\rangle$ are not vectors in $L^2(\mathbb R)$. To provide them with a rigorous mathematical meaning one should enlarge $L^2(\mathbb R)$ into an extended (non-Hilbert) vector space structure including Schwartz distributions or adopt a viewpoint based on the so called direct integral of Hilbert spaces. These are structures quite complicated to use with respect to a standard Hilbert space. Nevertheless the practical use of formal objects like $|x\rangle$ is quite efficient in physics provided one is able to distinguish between problems arising from physics and false problems just due to a naive misuse of the formalism.
(When I was student I wasted time in discussing if identities like $A|\psi\rangle = |A\psi \rangle$ had any sense.)
My reasoning is that while you can write any function with a finite number of jump discontinuities in the basis $| n\rangle$, the position basis vectors $\delta(x - x_0) = |x\rangle$ cannot be written as such. Hence they are not in that Hilbert space.