       Re: Replacement Rule with Sqrt in denominator

• To: mathgroup at smc.vnet.net
• Subject: [mg114003] Re: Replacement Rule with Sqrt in denominator
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Sat, 20 Nov 2010 06:14:12 -0500 (EST)

```Replacements are done on the FullForm. Look at the FullForm to understand the differences.

expr1 = Sqrt[-4 \[Zeta]^2 + (1 + \[Rho]^2)^2];

expr2 = 1/Sqrt[-4 \[Zeta]^2 + (1 + \[Rho]^2)^2];

rule1 = Sqrt[-4 \[Zeta]^2 + (1 + \[Rho]^2)^2] -> G;

expr1 // FullForm

rule1 // FullForm

expr2 // FullForm

Note that in the FullForm for both expr1 and rule 1 that the pattern is Power[_, Rational[1, 2]] so the replacement is made. However, in the FullForm for expr2 the pattern is Power[_,Rational[-1, 2]] so there is no match. You can generalize the rule

rule2 = (-4 \[Zeta]^2 + (1 + \[Rho]^2)^2)^Rational[a_, 2] -> G^a;

{expr1, expr2} /. rule2

{G, 1/G}

Or avoid the Power

rule3 = (-4 \[Zeta]^2 + (1 + \[Rho]^2)^2) -> G^2;

{expr1, expr2} /. rule3 // Simplify[#, G > 0] &

{G, 1/G}

Bob Hanlon

---- Themis Matsoukas <tmatsoukas at me.com> 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

```

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