Re: Vector algebra
- To: mathgroup at smc.vnet.net
- Subject: [mg65496] Re: Vector algebra
- From: "Valeri Astanoff" <astanoff at yahoo.fr>
- Date: Wed, 5 Apr 2006 06:55:39 -0400 (EDT)
- References: <e0r0nm$pn$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Here is a DIY way to do what you want : In[1]:=unDistribute[ex_Plus /; MatchQ[ex[[All,1]], _Integer*_] && MatchQ[ex[[All,2]], _ + __]] := ex[[All,1]][[2]] ~ex[[1,0]]~ ex[[All,2]]; unDistribute[ex_Plus /; MatchQ[ex[[All,2]], _Integer*_] && MatchQ[ex[[All,1]], _ + __]] := ex[[All,1]] ~ex[[1,0]]~ ex[[All,2]][[2]] ; In[3]:=x.a+x.b+x.c//unDistribute Out[3]=x.(a+b+c) In[4]:=%//Distribute Out[4]=x.a+x.b+x.c In[5]:=a.x+b.x+c.x//unDistribute Out[5]=(a+b+c).x In[6]:=%//Distribute Out[6]=a.x+b.x+c.x hth (and hoping someone will post something simpler!) V.Astanoff