# Trying to show new matrix elements of momentum operator after unitary transformation of $|x \rangle$

The problem is this. Given that I have a new x basis $$|\tilde{x} \rangle = e^{i g(X)/ \hbar} |x\rangle$$ I have to show that $$\langle \tilde{x} | P | \tilde{x}' \rangle = \left(-i \hbar \frac{d}{dx} + \frac{dg}{dx}\right) \delta (x-x').$$

Here is my attempt at a solution

$$\langle \tilde{x} | P | \tilde{x}' \rangle= \int \int \langle \tilde{x}| x \rangle \langle x | P | x' \rangle \langle x' | \tilde{x}' \rangle dx' dx$$

$$= \int e^{-ig(x)/ \hbar} \int -i \hbar \delta'(x-x') e^{i g(x')/ \hbar} dx' dx$$ But this doesn’t give the correct result. I suspect my mistake is thinking that the projection of $$\tilde{x}$$ in the old x basis is $$e^{ig(x)/\hbar}$$. If that is really my mistake, then what is the projection? If that isn't, well then what am I doing wrong and how do I do this correctly?

We know that for any function $$f$$, we have : $$[P,f(X)]= -i\hbar f'(X)$$
$$\left[P,e^{ig(X)/\hbar}\right] = g'(X)e^{ig(X)/\hbar}$$
Now, we can compute : \begin{align} \langle \tilde x |P |\tilde x'\rangle &= \langle x|e^{-ig(X)/\hbar}Pe^{ig(X)/\hbar}|x'\rangle \\ &= \langle x |g'(X) + P|x'\rangle \\ &= \left(g'(x) - i\hbar \frac{\text d }{\text dx}\right)\delta(x-x') \end{align}