Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: [mg4433] Replacement
Posted:
Jul 30, 1996 2:58 AM
|
|
ges@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@haystack.demon.co.uk
|
|
|
|