Kashmir said:
Using the tensor product formalism in which ##\hat{P}|\psi\rangle=\left(\hat{P}_{x} \otimes \mathbb{1} \otimes \mathbb{1}\right)|\psi\rangle+\ldots##
I found ##\langle r|\hat{P}| \psi\rangle=\left(\frac{\hbar}{i} \frac{\partial}{\partial x} \psi+\frac{\hbar}{i} \frac{\partial}{\partial y} \psi+\frac{\hbar}{i} \frac{\partial}{\partial z} \psi\right).
## . This doesn't have any spatial unit vectors in it.
But in *Townsends Quantum mechanics* he says that ##\langle\mathbf{r}|\hat{\mathbf{p}}| \psi\rangle=\frac{\hbar}{i} \nabla\langle\mathbf{r} \mid \psi\rangle##. This has spatial unit vector.
How to reconcile the two now?
Let's start with what we know. We have an abstract state ##|\psi \rangle##. We know this has a position space representation as a wave-function of three real variables (equivalent to one 3D Euclidean vector). So:
$$ |\psi \rangle \leftrightarrow \psi(x, y, z) \equiv \psi(\vec r)$$Here ##\vec r## is a simple 3D Euclidean vector. Now, we know (or suspect) that the momentum operator acting on a position space wave-function takes the form of a gradient:
$$\hat p |\psi \rangle \leftrightarrow -i \hbar \nabla \psi(x, y, z)$$There are two immediate issues. First, the wave-function is compex valued, so the RHS is not a vector in 3D Euclidean space. It's some vector with three components. You could introduce unit vectors ##e_x, e_y, e_z## but the whole construction is not a simple 3D real Euclidean vector.
The second issue is that the LHS must have three components. There must be some way of representing the Hilbert space so that it is associated with the 3D nature of the gradient. One idea is that we have three compatible position operators ##\hat x, \hat y, \hat z##, which have eigenstates ##| x \rangle, |y \rangle, |z \rangle## that together form an uncountable basis for our Hilbert space. Informally we can combine these into one "vector" position eigenstate:
$$\mathbf r \equiv |x, y, z \rangle$$Note that ##\mathbf r## is not really a vector here, it's just a convenient shorthand. Many QM books will continue under the assumption that we don't need to delve any deeper into the structure of Hilbert spaces. If you do delve deeper, then you need the concept of a tensor product of Hilbert spaces and operators. When the dust settles you end up with:
$$ \hat p |\psi \rangle \equiv \hat p_x \otimes \hat p_y \otimes \hat p_z |\psi \rangle \leftrightarrow -i \hbar \nabla \psi(x, y, z)$$Where ##|\psi \rangle## can be expressed as a tensor product as above:
$$|\psi \rangle = \int_{\mathbb{R}} \mathrm{d} x \int_{\mathbb{R}} \mathrm{d} y \int_{\mathbb{R}} \mathrm{d} z \ \psi(x, y, z) |x \rangle \otimes |y \rangle \otimes |z \rangle.$$And everyting should make sense. We see that the position-space wave-function comes from the coefficients of the state in the position basis. And the momentum operator acting on that corresponds to the gradient of the position space wave-function.
The final step is to take the inner product with the bra ##\langle \mathbf r |## to get the "equality":
$$\langle \mathbf r |\hat p |\psi \rangle = -i \hbar \nabla \psi(x, y, z)$$And, we can see that this really means:
$$\langle x |\hat p |\psi \rangle = -i \hbar \frac{\partial}{\partial x} \psi(x, y, z)$$$$\langle y |\hat p |\psi \rangle = -i \hbar \frac{\partial}{\partial y} \psi(x, y, z)$$$$\langle z |\hat p |\psi \rangle = -i \hbar \frac{\partial}{\partial z} \psi(x, y, z)$$And you have to accept that this is what Townsend means. Note that I chose not to represent the momentum operator as a bold-face vector. That highlights that we have to take these equations as symbolic. You can't take the first equation too literally. If you try to add Euclidean basis vectors, then you are pushing the correspondence too far.