MathGroup Archive 1996

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

Search the Archive

Re: Replacement


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?!