MathGroup Archive 1996

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

Search the Archive

Re: Sqrt Tip

  • Subject: [mg3035] Re: Sqrt Tip
  • From: danl (Daniel Lichtblau)
  • Date: 25 Jan 1996 05:29:14 -0600
  • Approved: usenet@wri.com
  • Distribution: local
  • Newsgroups: wri.mathgroup
  • Organization: Wolfram Research, Inc.
  • Sender: mj at wri.com

In article <4e4ne5$6pj at dragonfly.wri.com> BobHanlon at aol.com writes:
> Mathematica version 2.2 on a Macintosh does not simplify the product 
> of square roots:
> 
> In[1]:=
> Sqrt[x] Sqrt[y] // Simplify
> 
> Out[1]=
> Sqrt[x] Sqrt[y]
> 
> As a result, it overlooks some straightforward simplifications.  
> For example,
> 
> In[2]:=
> Sqrt[1-x] Sqrt[1+x]/Sqrt[1 - x^2] // Simplify
> 
> Out[2]=
> Sqrt[1 - x] Sqrt[1 + x]
> -----------------------
>                2
>      Sqrt[1 - x ]
> 
> One would like to modify the definition of Sqrt to correct this as 
> follows:
> 
> In[3]:=
> Unprotect[Sqrt];
> Sqrt/: Sqrt[a_] Sqrt[b_] := Sqrt[a b];
> Protect[Sqrt];
> 
> This generates the error message
> 
> TagSetDelayed::tagnf: 
>    Tag Sqrt not found in Sqrt[a_] Sqrt[b_].
> 
> The reason that this failed is apparent if the FullForm of Sqrt is 
> inspected
> 
> In[6]:=
> Sqrt[x] // FullForm
> 
> Out[6]//FullForm=
> Power[x, Rational[1, 2]]
> 
> Sqrt is represented internally using Power.  Consequently, the 
> modification must be made to Power rather than Sqrt.
> 
> In[7]:=
> Unprotect[Power];
> Power/: Sqrt[a_] Sqrt[b_] := Sqrt[a b];
> Protect[Power];
> 
> After, modifying Power we obtain the desired result:
> 
> In[10]:=
> Sqrt[1-x] Sqrt[1+x]/Sqrt[1 - x^2] // Simplify
> 
> Out[10]=
> 1
> _______________
> 
> Bob Hanlon
> bobhanlon at aol.com
> 
> 

  When you try this cahnge to Power on the input Sqrt[x]*Sqrt[x] you see  
two reasons not to do it automatically. First, you get Sqrt[x^2] instead  
of x, so it is not a simplification. Then there is the fact that the two  
are not mathematically equivalent....

  Daniel Lichtblau
  Wolfram Research


  • Prev by Date: Re: Sqrt Tip
  • Next by Date: Re: Re: Q: Symbolic manipulation with Mathematica
  • Previous by thread: Re: Sqrt Tip
  • Next by thread: a polyhedral function