Search All of the Math Forum:

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

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

 Messages: [ Previous | Next ]
 David Park Posts: 1,560 Registered: 5/19/07
Re: Manipulating square roots
Posted: Sep 11, 2010 5:45 AM

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?

Date Subject Author
9/10/10 alan
9/10/10 Peter Breitfeld
9/11/10 David Park