RE: simplifying operator experessions with Dot, Times a nd Plus
- To: mathgroup at smc.vnet.net
- Subject: [mg35506] RE: [mg35481] simplifying operator experessions with Dot, Times a nd Plus
- From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
- Date: Wed, 17 Jul 2002 02:08:52 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
> -----Original Message----- > From: JL [mailto:jl at aol.com] To: mathgroup at smc.vnet.net > Sent: Tuesday, July 16, 2002 10:50 AM > Subject: [mg35506] [mg35481] simplifying operator experessions with > Dot, Times and > Plus > > > I am trying to expand a large expression that has terms that look as > follows: > > -ex[0,1].(ex[0,1].ex[1,2]-ex[1,2].ex[0,1]) > > where ex[i,j] are unevaluated expressions. I would like > Mathematica to > simplify this and analogous expressions so that they read: > > ex[0,1].ex[1,2].ex[0,1]-ex[0,1].ex[0,1].ex[1,2] > > However, I cannot seem to find anything that will work. The > problem is that > I need to keep track of the order of the expressions ex[i,j]. > If Dot were > replaced by Times, there would be no problem whatsoever. > > If anyone knows how to help me with this problem, I would > greatly appreciate > it. > > Thanks, > > Jeremy Levy > jlevy at pitt.edu > > > > > Jeremy, perhaps this is all humbug, ... In[74]:= dotExpandRules = {a_ .(b_ + c__) :> a.b + a.Plus[c], (a_ + b__). c_ :> a.c + Plus[b].c, Dot[a___, \[Beta]_?NumericQ*Dot[b__], c___] :> \[Beta]*Dot[a, b, c]}; In[77]:= -ex[0, 1].(ex[0, 1].(2 ex[1, 2]) + 3 ex[2, 2] - ex[1, 2].ex[0, 1]).(5 ex[3, 0]) //. dotExpandRules Out[77]= -15 ex[0, 1].ex[2, 2].ex[3, 0] - 10 ex[0, 1].ex[0, 1].ex[1, 2].ex[3, 0] + 5 ex[0, 1].ex[1, 2].ex[0, 1].ex[3, 0] ...but regard this as an idea to try, test it and check for correctness. A crucial point here is to separate scalar objects from (symbols/expressions to become) tensors. There might be better ways to do that. (Or simpler, if your problem is restricted, e.g. all your vectors/tensors have Head "ex" in there symbolic form.) Make sure to set up the parentheses right in mixed expressions with Times and Dot when scalars are involved. Be cautious, -1 quite often creeps in! -- Hartmut