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

Topic: Manipulating square roots
Replies: 2   Last Post: Sep 11, 2010 5:45 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
David Park

Posts: 1,560
Registered: 5/19/07
Re: Manipulating square roots
Posted: Sep 11, 2010 5:45 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

The Presentations package has a routine FactorOut that is useful here. The
trick is to pull a "factor" out of an expression and then protect the result
so that Mathematica won't simplify it back.

FactorOut[factor, quotientfunction : Indentity, factorfunction :
Identity][expr] will pull factor out of expression and write the result as
factorfunction[factor] quotentfunction[Expand[expr/factor]].Factor would not
even have to be in expr. The functions, if not Identity, would most commonly
be HoldForm.

Here we go back and forth between the two forms.

Needs["Presentations`Master`"]

expr = Sqrt[a^2 - b^2];

step1 = MapAt[FactorOut[a^2, HoldForm], expr, 1]

step2 = Simplify[step1, a > 0] // ReleaseHold

Giving...

Sqrt[a^2 (1-b^2/a^2)]

a Sqrt[1 - b^2/a^2]

step3 = MapAt[FactorOut[1/a^2, HoldForm], step2, {2, 1}]

step4 = Simplify[step3, a > 0] // ReleaseHold

Giving...

a Sqrt[(a^2-b^2)/a^2]

Sqrt[a^2 - b^2]

This has the advantage of doing it by calculation, but a simple rule as you
wrote might be simpler. It depends on the context in which you are doing the
transformation.


David Park
djmpark@comcast.net
http://home.comcast.net/~djmpark/


From: alan [mailto:alansbarnett@verizon.net]

How can I get mathematica to bring a factor inside a square root? For
instance
a Sqrt(1-(b/a)^2) -> Sqrt(a^2-b^2) (if a is real and a > 0).
Also, how do I get Mathematica to perform the operation in reverse?





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-2017. All Rights Reserved.