# Question about the associativity of operators in quantum mechanics

I'd like to ask whether or not quantum operators are associative. Take for example (in one dimension) the momentum operator $$\hat{p} = -i \hbar (\mathrm{d}/\mathrm{d}x)$$ and the position operator $$\hat{x} = x$$ acting on some test function $$f$$ as $$\hat{p} \hat{x} f(x) \, .$$ Does it make a difference whether the order in which the operators act is $$(\hat{p}\hat{x}) f(x)$$ or $$\hat{p} (\hat{x} f(x))$$? For example, in the first case, the derivative from the momentum operator acts on the position operator producing $$1$$, clearly a different result from the latter case in which the derivatve operator acts on the product $$xf(x)$$. Does this make the operators non-associative, or am I missing something?

Operators do not act on operators; operators act on states (or wavefunctions, in your example). As such, the order of writing down the operators before a state determines their order of operation. The operator $$\hat{x}$$ acts on the wavefunction $$f(x)$$ to produce the wavefunction $$xf(x)$$. Then the operator $$\hat{p}$$ acts on the wavefunction $$xf(x)$$, to produce the wavefunction $$-i\hbar\frac{d}{dx}(xf(x))$$.
• @AccidentalFourierTransform Just consider, say. a translation operator and some creation operator that creates something at the position $x$. $\hat{T}_y \hat{a}(x) |-\rangle$, where $\hat{T}_y$ is the operator that generates as translation by $y$. Does it act on the operator or not? – user178876 Oct 21 '18 at 22:36
• @marmot The concept of associativity is really sort of moot here, which is what I was trying to get across in this answer. This is because $(\hat{p}\hat{x})f(x)=\hat{p}(\hat{x}f(x))$ by definition, because that's the only sensible definition consistent with the fact that operators act on states. You can say this situation demonstrates associativity if and only if you also say that the statement $(f\circ g)(x)=f(g(x))$ demonstrates associativity. Most people, I think, consider the latter to be the definition of composition of functions, and so the same should apply here. – probably_someone Oct 21 '18 at 22:47