       Re: Replacement

• To: mathgroup at smc.vnet.net
• Subject: [mg4531] Re: [mg4433] Replacement
• From: Allan Hayes <hay at haystack.demon.co.uk>
• Date: Wed, 7 Aug 1996 04:17:39 -0400
• Sender: owner-wri-mathgroup at wolfram.com

```ges at vsnhdd.cern.ch (Sergej Gerassimov)
[mg4433] Replacement
writes

> I have something like
> x/Sqrt[a^2+b^2]+Sqrt[a^2+b^2]/y
> and I'd like to substitute Sqrt[a^2+b^2] by r.
>
> x/Sqrt[a^2+b^2]+Sqrt[a^2+b^2]/y //. Sqrt[a^2+b^2]->r
> gives:
>
>       x         r
> ------------- + -
> Sqrt[a^2+b^2]   y
>
> (replace one only in the numerator)
> How to replace Sqrt[a^2+b^2] by r everywhere in the expression?

Serge:
Two suggestions

x/Sqrt[a^2+b^2]+Sqrt[a^2+b^2]/y /.
{Power[(a^2+b^2), p:1/2|-1/2]->r^Sign[p]}

x   r
- + -
r   y

x/Sqrt[a^2+b^2]+Sqrt[a^2+b^2]/y /.
{Sqrt[a^2+b^2]->r,1/Sqrt[a^2+b^2] ->1/r}

x   r
- + -
r   y

The reason is that what Mma sees is

FullForm[x/Sqrt[a^2+b^2]+Sqrt[a^2+b^2]/y]

Plus[
Times[Power[Plus[Power[a, 2], Power[b, 2]], Rational[-1, 2]], x],
Times[
Power[Plus[Power[a, 2], Power[b, 2]], Rational[1, 2]],
Power[y, -1]
]
]

The Sqrt has gone.

Allan Hayes
hay at haystack.demon.co.uk

==== [MESSAGE SEPARATOR] ====

```

• Prev by Date: Re: Pairings
• Next by Date: Re: Re; Reordering lists?!
• Previous by thread: Re: Pairings
• Next by thread: Re: Re; Reordering lists?!