Let $P_x = \frac{\hbar}{i}\frac{d}{dx}$, after specifying the commutator relation symbolically $[X, P_x] = i\hbar$, I can ask Mathematica to calculate commutator algebra. My question: is there a way for Mathematica to directly calculate this commutator without me specifying it? I've tried after searching and reading pure functions

x*(D[#, x] &) - (D[#, x] &)*x

but it doesn't quite compute correctly.

  • $\begingroup$ Please make use of the search bar on top of this site; this question has been asked at least a dozen times before. $\endgroup$ – Henrik Schumacher Jan 11 at 17:17
  • $\begingroup$ For computing it directly, maybe the following will help: In[420]:= Together[ Through[(Composition[x*# &, D[#, x] &] + Composition[-D[#, x] &, x*# &])[f[x]]]/f[x]] Out[420]= -1 $\endgroup$ – Daniel Lichtblau Jan 11 at 18:38
  • $\begingroup$ Thanks for the quick line Daniel! After more searching, I found a nice answer by Jens here $\endgroup$ – Histoscienology Jan 11 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.