MathGroup Archive 1992

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Expand on RHS of rule

  • To: mathgroup at
  • Subject: Re: Expand on RHS of rule
  • Date: Sat, 30 May 1992 17:32 MST

Athos Kasapi asks:

>  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 ]

What is happening here is that the Expand[x y] is being evaluated
before the substitution of values for x and y. What you need is the
RuleDelayed operator (see p. 258):

p /. Sqrt[x_ y_] :> Sqrt[Expand[x y]]

Todd Gayley
Department of Ecology and Evolutionary Biology
University of Arizona
tgayley at

  • Prev by Date: Re: Expand[] on the RHS of a rule
  • Next by Date: Platform speeds
  • Previous by thread: text in graphics
  • Next by thread: Platform speeds