Say I have a hamiltonian $H=p_x^2+p_y^2+x^2+y^2+x^4+y^4$, and I want to calculate the commutator $\left[A,B\right] \equiv AB-BA$ of arbitrary operators $\mathcal{O}=x^ap_x^by^cp_y^d$, where $a,b,c,d\in\mathbb{N}$, subject to 2 simple rules.
- $\left[x,y\right]=\left[p_x,p_y\right]=\left[x,p_y\right]=\left[y,p_x\right]=0\ $ and $[x,p_x]=[y,p_y]=i$. These are the usual commutation relations of quantum mechanics.
- Another rule I want to impose is that all the $p$'s to be at the right and all the $x$'s to be on the left.
I want to define such a commutator operation and simply the expression $\left[H,\mathcal{O}\right]$ with the rules I have expressed earlier.
Are there any existing Mathematica packages that can achieve this purpose. If there is no such package, how should I go about creating my own?