Re: Expand[] on the RHS of a rule
- To: mathgroup at yoda.physics.unc.edu
- Subject: Re: Expand[] on the RHS of a rule
- From: ags at seaman.cc.purdue.edu (Dave Seaman)
- Date: Thu, 28 May 92 09:30:21 EST
athos at warp.stanford.edu (Athos Kasapi) writes: >Has anybody found a way to work around the problem that Expand does not >work when it is on the right hand side of a rule? For example, if I >define > >p := Sqrt[ (a + b) (c + d) ] > >and then apply the rule > >p /. Sqrt[ x_ y_ ] -> Sqrt[ Expand[ x y ] ] > >Then all I get back is > >Sqrt[ (a + b)(c + d) ] > >What I wanted was > >Sqrt[ ac + ad + bc + bd ] > >I'd appreciate any suggestions for getting around this. You specified immediate transformation by using "->", which means "Expand[x y]" is immediately evaluated to "x y", and then the resulting rule is applied. You need to use the ":>" operator to specify delayed transformation. The rule is p /. Sqrt[ x_ y_ ] :> Sqrt[ Expand[ x y ] ] in which the delayed transformation operator ":>" causes the product to be expanded after the substitution is made, rather than before. Dave