MathGroup Archive 1999

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

Search the Archive

Re: Simple edit ...

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19329] Re: [mg19319] Simple edit ...
  • From: "David Park" <djmp at earthlink.net>
  • Date: Mon, 16 Aug 1999 02:14:58 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Michael Stokes wrote;

>Consider the following examaple;
>
>z = (a+Sqrt[d+e])/(a Sqrt[d+e])
>
>z //. Sqrt[d+e] ->L
>
>The replacement function only replaces the instance of Sqrt[d+e] in the
>numerator and leaves the instance in the denominator alone.  Why does
>this not work and what is the work around?
>
>Regards,
>Mike
>
Mike,

This is a very common error. Look at the FullForm of z.

FullForm[z]
Times[Power[a, -1], Power[Plus[d, e], Rational[-1, 2]],
  Plus[a, Power[Plus[d, e], Rational[1, 2]]]]

The expression in the denominator that you wish to match is actually of the form
Power[Plus[d, e], Rational[-1, 2]] and Power[Plus[d, e], Rational[1, 2]] does not
match it. This would work:

z /. Power[d + e, Rational[n_, 2]] -> L^n
(a + L)/(a*L)

Item in the denominator always require care when matching with rules.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



  • Prev by Date: Re: Element Extraction
  • Next by Date: Re: circumference of an ellipse
  • Previous by thread: Re: Simple edit ...
  • Next by thread: Re: Simple edit ...