The fundamental relation between the position and momentum basis in quantum mechanics is summed up in the canonical commutation relation: $[x,p]=i\hbar.I$ From here, one can get to the matrix elements $\langle x |P|x'\rangle =-i\hbar\frac{\partial}{\partial x}\delta(x-x')$ using the fact: $(x-x').\delta(x-x')=0$. However, this representation is not unique. One can see this from the very fact that $-i\hbar \frac {\partial} {\partial x}+f(x)$ as the momentum operator in the postion basis will satisfy the commutation relation just as perfectly. But I am struggling to see how exactly one takes care of this extra degree of freedom from the fundamental CCR.
Shankar suggests if one makes an unitary transformation (I guess inspired by the Stone Von Neumann theorem) of the X basis: $|x \rangle \to |y\rangle=e^{\frac{ig(X)}{\hbar}}|x\rangle=e^{\frac{ig(x)}{\hbar}}|x\rangle $, the X operator will have the same matrix elements as before which is easily seen. But I can't figure out a way to get the P matrix elements in this rotated basis which are supposed to be:
$\langle y |P|y'\rangle =[-i\hbar\frac{\partial}{\partial x}+ f(x)]\; \delta(x-x')$ where $f(x)=\frac{d g}{d x}$
I gave it a try as shown below but wasn't able to calculate the messy integral at the end. Any help in this regard would be really appreciated!
$\begin{align} \langle y |P|y'\rangle &=\int dx_1\int dx_2 \; \;\langle y |x_1 \rangle \langle x_1 |P| x_2\rangle \langle x_2 |y' \rangle \\ & = \int dx_1\int dx_2 \; \;(e^{\frac{-ig(x_1)}{\hbar}} \delta(x_1-x) ).( -i\hbar\frac{\partial}{\partial x_1}\delta(x_1-x_2)). (e^{\frac{ig(x_2)}{\hbar}}\delta(x_2-x'))\\ &= \qquad ? \end{align}$
I suspect these is some kind of integration by parts involved here but there is just too many delta functions for me to handle this carefully.