Re: symbolic matrix manipulation

*To*: mathgroup at smc.vnet.net*Subject*: [mg96196] Re: symbolic matrix manipulation*From*: "Steve Luttrell" <steve at _removemefirst_luttrell.org.uk>*Date*: Mon, 9 Feb 2009 05:33:26 -0500 (EST)*References*: <gm99t7$70$1@smc.vnet.net>

For this sort of operator manipulation it is best to avoid using any of the Mathematica's prior knowledge of matrix/vector manipulations, and to instead define all your own functions. So, if you write an operator product in the form opprod[op1,op2,...], then you can reorder a-operators to the right of b-operators by defining the following rule: opprod[u___, a, b, v___] := opprod[u, b, a, v] + opprod[u, v]; As required, this simplifies opprod[a, b, b, a] to 2 opprod[b, a] + opprod[b, b, a, a] Here is another example: opprod[a,b,b,a,a,b,b,a] 4 opprod[b,a]+14 opprod[b,b,a,a]+8 opprod[b,b,b,a,a,a]+opprod[b,b,b,b,a,a,a,a] You can do lots more using this opprod[] approach. For instance, assuming that your a- and b-operators are corresponding annihilation and creation operators, then you could define opprod[u___,a,b,v___]:=opprod[u,b,a,v]+opprod[u,v]; opprod[___,a,vacuum]:=0; opprod[]:=1; ("vacuum" means "ground state", which is annihilated by the a-operator) Then opprod[a, a, b, b] gives 2 + 4 opprod[b, a] + opprod[b, b, a, a] but opprod[a, a, b, b, vacuum] gives 2 opprod[vacuum] -- Stephen Luttrell West Malvern, UK <ashwin.tulapurkar at gmail.com> wrote in message news:gm99t7$70$1 at smc.vnet.net... > Hi, > I am trying to simplify the following matrix expression: > a.b.b.a with the rule: replace a.b by (b.a+1). So I expect the final > output to be > a.b.b.a --> (b.a+1).b.a --> b.a.b.a+b.a --> b.(b.a+1).a+b.a --> > b.b.a.a + 2 b.a > > Can you tell me how to do this? > > Thanks. > -Ashwin >