# Evaluating the position operator in momentum space

I'm a bit lost with the following derivation: \begin{equation} \begin{aligned} \left\langle p^{\prime}|x| p^{\prime \prime}\right\rangle & =\int\left\langle p^{\prime}|x| x^{\prime}\right\rangle\left\langle x^{\prime} \mid p^{\prime \prime}\right\rangle d x^{\prime}=\int x^{\prime}\left\langle p^{\prime} \mid x^{\prime}\right\rangle\left\langle x^{\prime} \mid p^{\prime \prime}\right\rangle d x^{\prime} \\ & =\frac{1}{2 \pi \hbar} \int x^{\prime} \exp \left[-i \frac{\left(p^{\prime}-p^{\prime \prime}\right) \cdot x^{\prime}}{\hbar}\right] d x^{\prime} \\ &=i \frac{\partial}{\partial p^{\prime}} \frac{1}{2 \pi} \int \exp \left[-i \frac{\left(p^{\prime}-p^{\prime \prime}\right) \cdot x^{\prime}}{\hbar}\right] d x^{\prime} \\ & =i \hbar \frac{\partial}{\partial p^{\prime}} \delta\left(p^{\prime}-p^{\prime \prime}\right) \end{aligned} \end{equation}

In specific, how do we get from line 2 to 3 ? I'm confused because $$x^{\prime}$$ is a scalar value and it's somehow pulled out of the integral and gets transformed into an operator. I think there's also integration by parts, but the appearance of $$\frac{\partial}{\partial p^{\prime}}$$ in line 3 troubles me.

You can get $$x'$$ by differentiating the exponential with respect to $$p'$$, the derivative pulls down a factor of $$-ix'/\hbar$$. This is exactly what the second line is. The following identity has been used $$\frac{\partial }{\partial p'}\exp \left[-i \frac{\left(p^{\prime}-p^{\prime \prime}\right) \cdot x^{\prime}}{\hbar}\right] = -i\frac{x'}{\hbar}\exp \left[-i \frac{\left(p^{\prime}-p^{\prime \prime}\right) \cdot x^{\prime}}{\hbar}\right].$$ Plug this in the third line and you will get the second line.
$$\frac{\partial}{\partial p} e^{ipx} = i x e^{ipx}$$