Wavefunctions as Inner Product In the following expression, n and m belong to the number basis and x is the position:
$$
\langle n|m \rangle = \int_x n^*(x) m(x) dx = \int_x \langle n|x \rangle \langle x|m \rangle dx
$$
I understand $\langle n|m \rangle$ as the inner product of $|n\rangle$ and $|m\rangle$. However $\langle n|x \rangle$ and $\langle m|g \rangle$ make no sense to me. The reason is that the dimensions of number basis is countable infinite or finite (imagine harmonic oscillator or spin system), however, the dimensions of position is uncountable infinite. How can you take an inner product between vectors from different basis?
 A: I will not give a full answer, a lot of useful answers explaining technical details can be found in
Hilbert space of harmonic oscillator: Countable vs uncountable?
and maybe
On the dimensionality of the Hilbert space for a central potential
But I will try to explain what I think your question is about and try to give it a precise formulation. This turned out to be a bit too long for comments, so I went ahead and posted it as an answer...

*

*It is entirely unproblematic to take inner products between vectors from different bases. By themselves, they are just vectors. I think the problem you have is another one, so let me make a guess and see whether I understand the question correctly: You are confused by the fact that you can either expand your state in the uncountable basis $|x\rangle$ or in the countable basis $|n\rangle$. But the basis of a space should be either countable or uncountable, so what's the missing detail?


*If that is roughly what you wanted to ask, let me point out how your question could be formulated more precisely: If you have two spaces $V$ and $H$, and the basis of $H$ is countable while the basis of $V$ isn't, clearly $H$ and $V$ are very different spaces (in math speech, they are not isomorphic, and you don't need a Hilbert space structure here, topological vector spaces are enough). But then we must conclude that we can't have a countable and an uncountable basis for one and the same space. So we must conclude that $|x\rangle$ and $|n\rangle$ are bases for different vector spaces, and how on earth do you take inner products between vectors in different spaces?


*tparker's answer in Hilbert space of harmonic oscillator: Countable vs uncountable?
should give you everything you need to continue from here if you want the technical details, otherwise look through the other answers there.
