Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Replacement Rule with Sqrt in denominator

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113990] Re: Replacement Rule with Sqrt in denominator
  • From: kj <no.email at please.post>
  • Date: Sat, 20 Nov 2010 06:11:41 -0500 (EST)
  • References: <ic5igm$44p$1@smc.vnet.net>

In <ic5igm$44p$1 at smc.vnet.net> Themis Matsoukas <tmatsoukas at me.com> writes:

>This replacement rule works,

>Sqrt[-4 \[Zeta]^2 + (1 + \[Rho]^2)^2] /. 
> Sqrt[-4 \[Zeta]^2 + (1 + \[Rho]^2)^2] -> G

>G

>but this doesn't:

>1/Sqrt[-4 \[Zeta]^2 + (1 + \[Rho]^2)^2] /. 
> Sqrt[-4 \[Zeta]^2 + (1 + \[Rho]^2)^2] -> G

>1/Sqrt[-4 \[Zeta]^2 + (1 + \[Rho]^2)^2]

>The only difference is that the quantity to be replaced is in the denominator. If I remove Sqrt from the replacement rule it will work but I don't understand why a square root in the denominator (but not in the numerator) causes the rule to fail. 


Yes, that's very annoying.

The reason is that the pattern matching is done on the full forms
of the expressions, which is not always immediately obvious.  To
see this compare FullForm[Sqrt[x]], which is
Power[x, Rational[1, 2]], with FullForm[1/Sqrt[x]], which is
Power[x, Rational[-1, 2]].

I don't know a way to write the replacement rule so that it works
for both Sqrt[x] and 1/Sqrt[x], but maybe someone else does.

~kj


  • Prev by Date: Re: Replacement Rule with Sqrt in denominator
  • Next by Date: Re: Replacement Rule with Sqrt in denominator
  • Previous by thread: Re: Replacement Rule with Sqrt in denominator
  • Next by thread: Re: Replacement Rule with Sqrt in denominator