Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1992
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1992

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

Search the Archive

Re: Expand on RHS of rule

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: Re: Expand on RHS of rule
  • From: TODD GAYLEY <TGAYLEY at ccit.arizona.edu>
  • 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 ccit.arizona.edu





  • 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