MathGroup Archive 1998

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

Search the Archive

RE: Sqrt problem - restated




Paul Reiser  wrote:
 ----------
| How do I get "2" out of this:
|
|    Sqrt[a - b] Sqrt[a + b]
|1 + -----------------------
|               2    2
|         Sqrt[a  - b ]
|
|I'm starting to understand why Mathematica doesn't deal with this
|because of the multiple value of square root, but if I know everything
|under the square roots are positive, can I reduce this to 2 somehow
|without substitution? (substitution would be prohibitively tedious in
|my case)
|
|

Unfortunately Mathematica doesn't have this capability built-in (not yet
anyway).  We can write a program to handle this case and many others. 
 Caution:  I haven't done extensive testing on this program.

At the very least it should be interesting, and a good start to boot.

Very similar to my recent solution to  Manual's question I define the 
functions AssumedInterval, Assume, IntervalExpr, UseAssumptions.  Then
I  define the rules AssumptionRules, and SimplifyRules.

________________________________

In[10]:=
AssumedInterval[x_]:=x


In[11]:=
Assume[x_,Positive]/;(NumericQ[x]===False):=
     (AssumedInterval[x]^=Interval[{$MinNumber^(1/20),Infinity}];)


In[12]:=
Assume[x_,Negative]/;(NumericQ[x]===False):=
     (AssumedInterval[x]^=Interval[{-Infinity,-$MinNumber^(1/20)}];)


In[13]:=
IntervalExpr[expr_]:=With[
          {temp=Map[AssumedInterval[#]&, expr,{-1}]},
          If[TrueQ[FreeQ[temp,f_[_Interval..]]],temp, Indeterminate]]


In[14]:=
AssumptionRules={
Greater[a_,b_]:>With[{tempa=IntervalExpr[a],tempb=IntervalExpr[b]},
Which[Min[tempa]>Max[tempb],True,Max[tempa]<=Min[tempb],False, True,
Greater[a,b]]/;
(Head@tempa===Interval||Head@tempb===Interval)],
          
Less[a_,b_]:>With[{tempa=IntervalExpr[a],tempb=IntervalExpr[b]},
Which[Max[tempa]<Min[tempb],True,Min[tempa]>=Max[tempb],False, True,
Less[a,b]]/;
(Head@tempa===Interval||Head@tempb===Interval)],

Im[x_]:>0/;MatchQ[IntervalExpr[x],Interval[{_,_}]]     };


In[15]:=
UseAssumptions[expr_]:=expr//.AssumptionRules


In[16]:=
SimplifyRules={
Sqrt[x_]*Sqrt[y_]:>Sqrt[x*y]/;
          (Or@@UseAssumptions/@{x>0,y>0})&&
          (And@@UseAssumptions/@{Im[x]==0,Im[y]==0}),
     
(x_^pwr_Rational)(y_^pwr_Rational):>(x*y)^pwr/;
               Or@@UseAssumptions/@{x>0,y>0},
               
Sqrt[x_]:>Sqrt[Factor[x]],
          
(x_)^(pwr_Rational):>Factor[x]^pwr};

_________________________________

Now I state that (a) and (b) are Positive, and I get the simplification
you  want.
Note:  The simplification hold true when (a-b) is Negative.


In[17]:=
Assume[a,Positive];
Assume[b,Positive];


In[18]:=
1+Sqrt[a+b]Sqrt[a-b]/Sqrt[a^2-b^2]//.SimplifyRules

Out[18]=
2

_______________
Ted Ersek

PS
Paul,  You work at NRL?
I work at NAWCAD  PatuxentRiver, MD.




  • Prev by Date: Mathematica 3.0 preferences-file
  • Next by Date: Re: Exporting (saving) data
  • Prev by thread: RE: Sqrt problem - restated
  • Next by thread: Re: Sqrt problem - restated