The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Inactive » comp.soft-sys.math.mathematica

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Re: [mg4433] Replacement
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Allan Hayes

Posts: 1,508
Registered: 12/6/04
Re: [mg4433] Replacement
Posted: Jul 30, 1996 2:58 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply (Sergej Gerassimov)
[mg4433] Replacement

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

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


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

The Sqrt has gone.

Allan Hayes

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.