In general quantum mechanics we represent the state of a system with a state vector $| \psi \rangle $ in some Hilbert space in some base. Assuming a complete discrete set of bases vectors $ |n \rangle $ we can write the state $\psi $ as:
$$| \psi \rangle = \sum_n ^N c_n |n \rangle $$
Having by definition an inner product we can see that $c_n = \langle \psi | n \rangle $. This is the projection of the state vector on the base vector $n$. This coefficient squared, we say, gives us the probability of finding out system in the state $n$.
As I understand so far $ c_n $ is a complex number. Also, as a function, $\psi$ is a function of variable same as the variable of $n$, where $n$ are also functions.
In position representation we have a base denoted as $| x \rangle $. So to the question.
I would say that:
$$| \psi \rangle = \sum_n ^N c_n |x \rangle $$
$$c_n = \langle x| \psi \rangle $$ where $|x \rangle =f(x) $ so that, in this bases $| \psi \rangle = \psi (x)$, x meaning position.
My problem is that from what I read, what holds is this:
$$c_n = c_n (x) = \langle x | \psi \rangle = \psi (x) ,$$ $ \psi (x)$ being the wavefunction- the projection of $|\psi \rangle $ on $|x \rangle $ and
$$\psi(x) = \sum_n ^N c' _n u_n (x) $$, where $ u_n (x)$ constitute a base for the position representation. So, the probability of finding the particle in position $x$ is $| \psi (x) |^2 $. But I thought that $|x \rangle $ was already our base in space.
Are $u(x) $ and $| x \rangle $ the same or not? If not, why do we need $u(x)$?
Is $\psi (x) $ as given in the end by the inner product a function that can be expressed in functions of $x$ that constitute a base or is it a number as a result of an inner product giving the coefficient in a sum? Can the coefficients be functions and if yes, when? Is it correct to say that the wavefunction in secondary to the state vector and if so, how is it a function if it is a coefficient?
There is certainly something here I don't get and I would really like your help and clarifications.
Note: I wrote the question with sums and not integrals for convenience. An answer might have as well integrals, there is clearly no problem. Also I' ve had a look in these questions and answers:
General wavefunction and Schrödinger Equation
State of a system in Quantum Mechanics and state vectors
Representations in quantum mechanics
Vector representation of wavefunction in quantum mechanics?
but I'm not sure they address my problem.