MathGroup Archive 2010

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

Search the Archive

Re: Replacement Rule with Sqrt in denominator

Themis Matsoukas wrote:

> 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. 
> Themis

Have a look at the FullForm, which is always used by ReplaceAll:

In your first example the FullForm looks like:


In the second one:


the little but important difference is the "-" Sign in the last one. In
the first example the replacement takes place, because the FullForm
matches. You do ff1/.ff1->G

But in the second one it doesn't match because you try ff2/.ff1->G

You can do:  ff2/. (1/ff1)->G  (no need to use FullForm here)

Peter Breitfeld, Bad Saulgau, Germany --

  • Prev by Date: Re: How to work with In?
  • Next by Date: Re: Mathematica 8
  • Previous by thread: Re: Replacement Rule with Sqrt in denominator
  • Next by thread: Re: Replacement Rule with Sqrt in denominator