Commutator of two functions I want to compute the commutation relation between a function of momentum and a function of space in Quantum Mechanics. I know the commutation relation between momentum and a function of space but how can I compute the commutation relation between functions of momentum $p$ and space $x$? Some thing such as
$[f(x),g(p)]$
 A: There are dozens of tricks to do this, but most of them reside in phase-space quantization, with which you are likely unfamiliar if you are asking this, so I'm staying out of it. Let's skip the hats for operators, set $\hbar=1$ for simplicity, non-dimensionalizing, and work in the coordinate representation, so, essentially, p is shorthand for $p=-i\partial_x$.
You are then seeking $[g(p),f(x)]$.You already said you have
$$
[p,f(x)]= -i f'(x),
$$
from which you may compute the following
$$
[p^2,f(x)]=p[p,f]+ [p,f]p \\ = -ipf'(x) -i f'(x) p = -f''(x)-2if'(x)p,
$$
and likewise for all monomials in p, whence all polynomials, by linearity of the commutator.
I assume you are familiar with the combinatoric tricks for monomials, which mathematicians like, but this is a bit barking up the wrong tree; most of them don't get their hands dirty in our messy world, nor have they any interest in that.
The  key point is to convince your self that, for a c-number y (not operator like p),
$$
[e^{iy p}, f(x)] = \bigl(f(x+y) -f(x)\bigr) e^{iyp},
$$
by virtue of the  fundamental Lagrange shift, with which you are familiar from the translation operator.
But every function g(p) is a linear combination of such exponentials, by virtue of its Fourier transform,
$$
g(p) = {1\over \sqrt{2\pi}}\int\!\! dy ~~e^{iyp} \tilde g(y)~~~~\leadsto \\
\tilde g(y)= {1\over \sqrt{2\pi}}\int\!\! dp ~~e^{-iyp}  g(p).
$$
Consequently
$$
[g(p),f(x)]= {1\over \sqrt{2\pi}}\int\!\! dy ~~ \tilde g(y)~~[e^{iyp},f(x)]\\= {1\over \sqrt{2\pi}}\int\!\! dy ~\bigl (f(x+y)-f(x)\bigr )~ \tilde g(y) e^{iyp},
$$
a numerical integral of functions in coordinate space when acting on a constant or translationally invariant state.
A: I don't think you can do it unless You are given what $f(x)$ and $g(p)$ are. If they are given you can use different properties for commutation relation and $[x,p]=i\hbar$ to compute what $[f(x),g(p)]$ will be.

Consider a simple example (More complicated function may not solve this way)
$$[x^2,p]=x[x,p]+[x,p]x=xi\hbar+i\hbar x=2i\hbar x$$
Further generalization can be found here.
