views:

82

answers:

1

this is a little complicated. i spent 2 weeks on this, so i'd love ur input or suggestion how to figure it out or where to post.

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 inputed 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 a package http://homepage.cem.itesm.mx/lgomez/quantum/): http://dl.dropbox.com/u/8916126/post.nb

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: in the end, i'm trying to write a mathematica code that can get equations in appendix (eq. A2) in this papaer: http://dl.dropbox.com/u/8916126/Prezhdo02_8704.pdf . and http://dl.dropbox.com/u/8916126/henonHeiles7.nb is the code that i'm using. the code in henonHeiles7.nb is a little different from post.nb because i couldn't get the post.nb to run as well but post.nb would be ideal.

in the end i'd like to use the final code for other kind of hamiltonians upto 4th power or even higher.

I understand that i might not be clear about this so let me know if i can articulate better.

also i'd love an advice how i can learn how to write a package that can do targeted simplifications for me.

thank you,

--Kirill

+3  A: 

If you are just using rules to simplify (and I'm assuming that you mean that you use Replace[]) then there can be problems if the pattern you want to replace is present but not in the exact correct form. E.g., your example of Replace[q2*q1^2*p2,q2*p2->(p2*q2+q2*p2)/2] which will do nothing in this case (Note that writing q2*p2*q1^2 won't help either since Mathematica sorts all input before starting evaluation.

I have in the past encountered similar simplification problems with Mathematica and there are two strategies that have yielded reasonable success. I'm sorry I can't give you a specific solution, I hope these help you figure it out.

Solution 1: You have to write your own ReplaceUnordered[form,rule] function that parses through all the different orderings of form for possible applications of rule. This can be done with Permutations[] and the use of HoldForm[].

Solution 2: Use Simplify[]. Specifically use the option ComplexityFunction to make non-symmetrical expressions more "expensive", and the option TransformationFunctions to specify your own simplification rules.

Here (pdf) is a nice short(ish) introduction to Mathematica and it's constructs and the evaluation process.

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

EDIT: Extra Extra Bonus (possibly very easy) Solution: As rcollier pointed out SymmetricReduction[] might do what you want very easily.

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



Timo
+1, for `ComplexityFunction` and `TransformationFunctions`. I've been using Mathematica for years, and only within the last 2 have I discovered the usefulness of these two options.
rcollyer
Thanks, and yes, Simplify is very good if you know how to use those two, the one additional thing I would (figuratively) give an arm for is for Simplify to support `levelspec` like targeting.
Timo
Just to point out, the `Simplify` documentation gives an example using `PolynomialReduce` in the `TransformationFunctions`. For the OP's problem, `SymmetricReduction` will most likely give the results they're looking for.
rcollyer