Simplification and permutation of non-commutative variables in mathematics

In short, I have an expression that contains multiplications between p1 , p2 , q1 and q2 , and I would like to use [qi,pi]=ii*hb , where i={1,2} , to get the expression 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 with the help of simplification and some replacements. But I cannot simplify q2*q1^2*p2 , although I indicated the rule q2*p2-> (p2*q2+q2*p2)/2 +ii/2*hb and that the variables with 1s and 2s commute.

In more detail, here is the Mathematica code (I am using a quantum package ).

The code works if the index is 1 or 2, but does not work when both indices are used:

p2*q2*q1*q2 gives p2*q1*q2^2 , p2*q2*q2 can be simplified, but since q1 exists, Mathematica does not.

In even more detail: I am trying to write Mathematica code that can get equations into an application (eq A2.) In this paper, and this is the code that I use. The code in the last file is slightly different from the above code, because I could not get the above code, but it would be perfect.

In the end, I would like to use the latest code for other types of Hamiltonians to the 4th degree or even higher.

I would like advice on how I can learn to write a package that can make targeted simplifications for me.

+4
source share
1 answer

If you just use the rules for simplicity (and I assume you mean that you are using Replace[] ), then there may be problems if the template you want to replace is present, but not in the correct form. For example, your example is Replace[q2*q1^2*p2,q2*p2->(p2*q2+q2*p2)/2] , which will do nothing in this case (note that the entry q2*p2*q1^2 will not help either because Mathematica sorts all the input data before starting the evaluation.

In the past, I came across similar simplification problems with Mathematica, and there are two strategies that have given reasonable success. Sorry, I can’t give you a specific solution, I hope this helps you figure it out.

Solution 1: you should write your own function ReplaceUnordered[form,rule] , which parses all the various form orders for possible rule applications. This can be done using Permutations[] and using HoldForm[] .

Solution 2. Use Simplify[] . In particular, use ComplexityFunction to make asymmetric expressions more "expensive", and the TransformationFunctions option to specify your own simplification rules.

Here (pdf) is a short (ish) introduction to Mathematica, and it builds and evaluates the process.

Extra Bonus Solution: Use FORM , which is a language written specifically to solve the problem you have.

EDIT: An additional bonus (possibly very simple) Solution: Because rcollier indicated that SymmetricReduction[] can do what you want very easily.

And one more thing for the road: when I had to do calculations with non-commutative variables, I used this package, which contains algebra and calculus for Grassmann variables.



+5
source

All Articles