Apart, Factor on different operations
- To: mathgroup at smc.vnet.net
- Subject: [mg41293] Apart, Factor on different operations
- From: Paolo Bientinesi <pauldj at cs.utexas.edu>
- Date: Tue, 13 May 2003 04:20:39 -0400 (EDT)
- Organization: University of Texas at Austin
- Sender: owner-wri-mathgroup at wolfram.com
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