In short, I have an expression that contains multiplications between p1
, p2
, q1
and q2
, and I'd like to use [qi,pi]=ii*hb
, where i={1,2}
to get the expression to a symmetric form (pi^a*qi^b+qi^b*pi^a)/2
.
So for example, for p2*q2*p2^2
I get (p2*q2^3+q2^3*p2)/2 + 1/2*ii*p2^2*hb
using simplification and some replacements. But I cannot simplify q2*q1^2*p2
although I have specified a rule q2*p2-> (p2*q2+q2*p2)/2 +ii/2*hb
and that variables with 1s and 2s commute.
In more detail, here is the Mathematica code (I use the quantum package).
The code works when the index is either 1 or 2 but doesn't work when both indexes are used:
p2*q2*q1*q2
gives p2*q1*q2^2
, p2*q2*q2
can further be simplified but since there is q1
, Mathematica doesn't do it.
In even more detail: I'm trying to write a Mathematica code that can get equations in appendix (eq. A2) in this paper and this is the code that I'm using. The code in latter file is a little different from the code above because I couldn't get the code above to run as well but it would be ideal.
In the end I'd like to use the final code for other kind of Hamiltonians up to 4th power or even higher.
I'd love an advice how I can learn how to write a package that can do targeted simplifications for me.