I am trying to calculate $\langle x\ |\ \hat{x}\ |\ p\rangle$. I can work in the $x$-basis like so:
$$\langle x\ |\ \hat{x}\ |\ p\rangle=\int dx'\langle x\ |\ \hat{x}\ |\ x'\rangle\langle x'\ |\ p\rangle=\int dx'x'\langle x\ |\ x'\rangle\langle x'\ |\ p\rangle=x\langle x\ |\ p\rangle=\frac{xe^{ipx/\hbar}}{\sqrt{2\pi\hbar}}.$$
Which steps of this derivation are not correct, if any?
Second, if I try to do the same thing by using the $p$-basis representation of $\hat{x}$, I get into more trouble:
$$\langle x\ |\ \hat{x}\ |\ p\rangle=\int dp'\langle x\ |\ \hat{x}\ |\ p'\rangle\langle p'\ |\ p\rangle=\int dp'i\hbar\frac{\partial}{\partial p'}\langle x\ |\ p'\rangle\langle p'\ |\ p\rangle$$ $$=\int dp' (-\frac{xe^{ip'x/\hbar}}{\sqrt{2\pi\hbar}})\delta(p-p')=-\frac{xe^{ipx/\hbar}}{\sqrt{2\pi\hbar}}.$$
Hmmm - that doesn't look right - shouldn't the result be the same, no matter which basis or representation I use for $\hat{x}$? Where are the mistakes? Also, I'm not too confident with my own usage of the primes ' all over. Am I using those correctly?