Re: symbolic matrix manipulation

*To*: mathgroup at smc.vnet.net*Subject*: [mg96064] Re: symbolic matrix manipulation*From*: dh <dh at metrohm.com>*Date*: Wed, 4 Feb 2009 05:18:24 -0500 (EST)*References*: <gm99t7$70$1@smc.vnet.net>

Hi Ashwin, Dot is not automatically distributed over Plus. Therefore, we must teach it. The save way is to define your own dot operator. But for simplicity let me be a bit sloppy and chnage the built in definition of Dot: Unprotect[Dot]; x1__.(x2_ + x3__) = (x1.x2 + x1.x3) (x2_ + x3__).x1__ = (x2.x1 + x3.x1) x1__.(x2_ + x3__).x4__ = (x1.x2 + x1.x3).x4 Now we can apply a replacement rule several times: a.b.b.a //. a.b -> (b.a + 1) this gives: 1.b.a + b.1.a + b.b.a.a not yet what you want. Must must teach Mathematica that 1.b=b.1=b: 1 . x1_ = x1 x1_ . 1 = x1 now we get from: 2 b.a + b.b.a.a hope this helps, Daniel ashwin.tulapurkar at gmail.com wrote: > 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 >