What is $\hat{p}|x\rangle$? Trying to solve a QM harmonic oscillator problem I found out I need to calculate $\hat{p}|x\rangle$, where $\hat{p}$ is the momentum operator and $|x\rangle$ is an eigenstate of the position operator, with $\hat{x}|x\rangle = x|x\rangle$. It turns out that $\hat{p}|x\rangle$ should be equal to $-i\hbar\frac{ \partial |x\rangle }{\partial x}$. But what does this even mean? I'm not sure what to do with an expression like that. If I try to find $\langle x | \hat{p} | x_0 \rangle$, I end up with $-i\hbar \frac{\partial}{\partial x} \delta(x-x_0)$, which I'm pretty sure is not allowed even in physics, where we would scoff at phrases like "$\delta$ is really a distribution and not a function".
Edit: Motivation. I have solved Heisenberg's equation and found, for a Hamiltonian $H = p^2/2m + m\omega^2x^2/2$, that $\hat{x}(t) = \hat{x}_0 \cos(\omega t) + \frac{\hat{p}_0}{m\omega} \sin(\omega t)$. I am given that the initial state is $|\psi(0)\rangle = |x_0\rangle$, i.e., an eigenstate of position, and I have a hunch that by finding $\hat{x}(t)|x_0\rangle$ I might find a way to get $|\psi(t)\rangle$. But this is not what I need help with; I am now curious as to what $\hat{p}|x\rangle$ might be, never mind my original problem.
 A: Your state $\left|x\right>$ will have some expansion in the definite-energy basis of stationary states for the harmonic oscillator,
$$
\left|x\right> = \sum \alpha_n \left|n\right>.
$$
You can find all of these $\alpha_n$ by switching between $\hat x$  and the ladder operators,
\begin{align*}
\hat x &= \sqrt\frac{\hbar}{2m\omega} \left( a^\dagger + a \right) 
= \frac{x_0}{\sqrt2} \left( a^\dagger + a \right),
\end{align*}
where $x_0 = \sqrt{\hbar/m\omega}$ is the length scale for the potential.
Computing $\hat x \left|x\right> = x \left|x\right>$ gives us
\begin{align*}
x \sum \alpha_n \left|n\right>
&= \frac{x_0}{\sqrt2} \sum_{n=0}^\infty \alpha_n \left(
 \sqrt{n+1}\left|n+1\right> 
+
 \sqrt n \left|n-1\right>
\right)
\\
&= \frac{x_0}{\sqrt2} \left(
\alpha_1 \left|0\right>
+
\sum_{n=1}^\infty \big(
\alpha_{n-1}\sqrt n + \alpha_{n+1} \sqrt{n+1}
\big) \left|n\right>
\right)
\end{align*}
Matching the terms which multiply $\left|n=0\right>$ tells us that the eigenvalue of $\hat x$ is fixed by the ratio $\alpha_1/\alpha_0$, and the coefficients of all the other $\left|n\right>$ are fixed by a double recurrence relation.
In that basis, 
$$
\hat p = \frac{i\hbar}{x_0\sqrt2}\left( a^\dagger - a \right),
$$
and its effect on $\left|x\right>$ can be computed without any frightening derivatives-of-deltas.


To connect a little better with your question about modeling, here's a plot of an approximation to a position eigenstate $\left|x=x_0\right>$ truncated at $\left|n=50\right>$, along with the same approximation for $\hat p\left|x\right>$ and a numerical derivative. You can sort of see how $\left|x\right>$ will tend towards a $\delta$ function as terms with higher $\left|n\right>$ are included, and in what sense the shape of $\hat p\left|x\right>$ will tend towards $-\delta'$.
A: The formula you quote is sort of correct, but I would encourage you to flip it around. More specifically, the old identification of momentum as a derivative means that
$$\langle x |\hat p|\psi\rangle=-i\hbar\frac{\partial}{\partial x}\langle x |\psi\rangle,$$
and from this you can 'cancel out' the $\psi$ to get
$$\langle x |\hat p=-i\hbar\frac{\partial}{\partial x}\langle x |.$$
(More specifically, these are both linear functionals from the relevant Hilbert space into $\mathbb C$ and they agree on all states in the Hilbert space, so they must agree as linear functionals.) This is the form that you actually use in everyday formulations, so it makes the most sense to just keep it this way, though you can of course take its hermitian conjugate to find an expression for $\hat p|x\rangle$.
Regarding your discomfort at the derivative of a delta function, I should assure you it is a perfectly legitimate object to deal with. It is best handled via integration by parts: for any well-behaved function $f$
$$
\int_{-\infty}^\infty \delta'(x)f(x)\text dx
=
\left.\delta(x)f(x)\vphantom\int\right|_{-\infty}^\infty-\int_{-\infty}^\infty \delta(x)f'(x)\text dx
=
-f'(0).
$$
In essence, this defines a (different) distribution, which can legitimately be called $\delta'$. It is this distribution which shows up if you substitute $|\psi\rangle$ for $|x_0\rangle$ in my first identity:
$$\langle x |\hat p|x_0\rangle=-i\hbar\delta'(x-x_0).$$
