Question: expression manipulation (with Physics operators)

I'm trying to do some manipulation of expressions that contain products of scalars and non-commuting operators (as defined by the physics package). The worksheet below shows this on a particular example. I can imagine a long/tedious way to do this, but perhaps the two key steps outlined below might be easily handled by some pattern-matching maple trickery, that is obvious to the pros here? 

In short, I need to convert expressions of the general form:


expr:=alpha*Sx*Sz^2 + beta*Sy*Sz + gamma*Sz*Sy*Sx  + Sx + beta^2;

to something like:

expr3:=alpha*f([Sx,Sz, Sz]) + beta*f([Sy,Sz]) + gamma*f([Sz, Sy, Sx]) + f([Sx]) + beta^2;

... with the caveat that the 'Sk' are operators (and their products could be of an arbitrary length).


The context here (for those who care) is basically to use the nice handling of non-commutative algebra of the Physics package to write down some Heisenberg equations of motion for a given system, and then approximate those using a cummulant expansion (this is in practice really tedious to do by hand in even simple systems, but arguably the most painful part is trivially done by the physics' package nice handling and sorting of the non commuting oprators). That, in essence requires one to transform larger products of non-commuting operators into smaller products (so say approximating an expectation value of 3-operator product as a sum of 2-operator peoducts and single operators). 

If anyone has ideas how best to approach this in the maple-ish way, please let me know.




Init related stuff


[`*`, `.`, Annihilation, AntiCommutator, Antisymmetrize, Assume, Bra, Bracket, Check, Christoffel, Coefficients, Commutator, CompactDisplay, Coordinates, Creation, D_, Dagger, Decompose, Define, Dgamma, Einstein, EnergyMomentum, Expand, ExteriorDerivative, Factor, FeynmanDiagrams, FeynmanIntegral, Fundiff, Geodesics, GrassmannParity, Gtaylor, Intc, Inverse, Ket, KillingVectors, KroneckerDelta, LeviCivita, Library, LieBracket, LieDerivative, Normal, NumericalRelativity, Parameters, PerformOnAnticommutativeSystem, Projector, Psigma, Redefine, Ricci, Riemann, Setup, Simplify, SortProducts, SpaceTimeVector, StandardModel, SubstituteTensor, SubstituteTensorIndices, SumOverRepeatedIndices, Symmetrize, TensorArray, Tetrads, ThreePlusOne, ToContravariant, ToCovariant, ToFieldComponents, ToSuperfields, Trace, TransformCoordinates, Vectors, Weyl, `^`, dAlembertian, d_, diff, g_, gamma_]



{%Commutator(Sx, Sy) = I*Sz, %Commutator(Sy, Sz) = I*Sx, %Commutator(Sz, Sx) = I*Sy}


Setup(mathematicalnotation=true, hermitianoperators = {Sx, Sy, Sz}, algebrarules=algebra_rules);

[algebrarules = {%Commutator(Sx, Sy) = I*Sz, %Commutator(Sy, Sz) = I*Sx, %Commutator(Sz, Sx) = I*Sy}, hermitianoperators = {Sx, Sy, Sz}, mathematicalnotation = true]



Say i have an expression like this below. In principle, each term could be a product:

(scalar) * (some prodcut of opertors)

with some arbitrary number of operators.

expr:=alpha*Sx*Sz^2 + beta*Sy*Sz + gamma*Sz*Sy*Sx  + Sx + beta^2;

alpha*Physics:-`*`(Sx, Physics:-`^`(Sz, 2))+beta*Physics:-`*`(Sy, Sz)+gamma*Physics:-`*`(Sz, Sy, Sx)+Sx+beta^2


would like apply ave(expr) and end up with:

expr2:=alpha*ave(Sx*Sz^2) + beta*ave(Sy*Sz) + gamma*ave(Sz*Sy*Sx)+ ave(Sx)   + beta^2;

alpha*ave(Physics:-`*`(Sx, Physics:-`^`(Sz, 2)))+beta*ave(Physics:-`*`(Sy, Sz))+gamma*ave(Physics:-`*`(Sz, Sy, Sx))+ave(Sx)+beta^2


so basically need a rule that forces:

Next, given expr2, would like to be able to apply some transformation to all the ave(XXX) functions.
for simplicity let's assume that I would like a following transformation:

ave(A*B*C ....)->f([A, B, C, ...])

with each of A, B, C here being an operator.

However the crucial point is that if there are powers of operators, each one should get its own entry in the list. So for example:

ave(A*B^2)->f([A, B, B]).
So applying this transformation to expr2, should give:

expr3:=alpha*f([Sx,Sz, Sz]) + beta*f([Sy,Sz]) + gamma*f([Sz, Sy, Sx]) + f([Sx]) + beta^2;

alpha*f([Sx, Sz, Sz])+beta*f([Sy, Sz])+gamma*f([Sz, Sy, Sx])+f([Sx])+beta^2




Please Wait...