Re: Apart, Factor on different operations
- To: mathgroup at smc.vnet.net
- Subject: [mg41297] Re: Apart, Factor on different operations
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Wed, 14 May 2003 08:07:21 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <b9qajg$hun$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi, exp //. d_.*Dot[a_, b_] + e_.*Dot[c_, b_] :> Dot[d*a + e*c, b] helps not ... Regards Jens Paolo Bientinesi wrote: > > Hello, > here is what I am trying to do: > > let op[x,y] be a binary associative operation but not commutative, > say Dot: > > op[x_, y_ + z_] := op[x,y] + op[x,z] > op[x_ + y_, z_] := op[x,z] + op[y,z] > > op[x_, y_] := x.y > > and let > > term = x + y; > > now, > > exp = op[term, z] > > is > > x.z + y.z > > So far so good. > > What I am trying to do is to go back from > x.y + y.z to op[term, z] by means of pattern matching: > > exp /. term -> X > > is the operation I have to perform, expecting > > X.z > > but of course it doesn't work. > > If I were using the common Times operation instead of Dot > I could achieve the result using Apart or Factor: > > Apart[ x z + y z ] /. term -> X > > returns > > X z > > Does anyone have an idea? > > thanks a lot, > -- > Paolo > > pauldj at cs.utexas.edu paolo.bientinesi at iit.cnr.it