Re: InequalitySolve
- To: mathgroup at smc.vnet.net
- Subject: [mg37929] Re: [mg37767] InequalitySolve
- From: Adam Strzebonski <adams at wolfram.com>
- Date: Tue, 19 Nov 2002 20:59:24 -0500 (EST)
- References: <31F1A06E-F629-11D6-A38C-00039311C1CC@tuins.ac.jp>
- Sender: owner-wri-mathgroup at wolfram.com
For univariate systems InequalitySolve uses Solve rather than CylindricalAlgebraicDecomposition. The problem in this example is that Solve gives a real solution in a form in which it is not recognized as real by inequalities. In[1]:= e = (-1)^(2/3)(1/2-Sqrt[5]/2)^(1/3); In[2]:= Im[e] Out[2]= 0 In[3]:= e > 0 2/3 1 Sqrt[5] 1/3 Greater::nord: Invalid comparison with (-1) (- - -------) attempted. 2 2 2/3 1 Sqrt[5] 1/3 Out[3]= (-1) (- - -------) > 0 2 2 One can fix this problem by loading a file InequalitySolveFix.m containing the following code. (It redefines Solve when called from inside InequalitySolve code.) (* ------- Begin InequalitySolveFix.m ------- *) Unprotect[Algebra`InequalitySolve`InequalitySolve]; Clear[Algebra`InequalitySolve`InequalitySolve]; InequalitySolve`BugFlag=False; Algebra`InequalitySolve`InequalitySolve[ineqs_, vars_] /; Not[InequalitySolve`BugFlag] := Block[{InequalitySolve`BugFlag=True}, Algebra`InequalitySolve`InequalitySolve[ineqs, vars]] Unprotect[{Solve}]; Solve[a__]/;InequalitySolve`BugFlag := Block[{InequalitySolve`BugFlag=False}, RootReduce[Solve[a]]] Protect[{Solve}]; <<Algebra`InequalitySolve`; (* ------- End InequalitySolveFix.m ------- *) In[1]:= <<InequalitySolveFix.m In[2]:= N[InequalitySolve[x^6 - x^3 - 1 == 0 && 0 < x < 2, x] ] Out[2]= x == 1.17398 Best Regards, Adam Strzebonski Wolfram Research Andrzej Kozlowski wrote: > This seems to be a bug in InequalitySolve. However, there is no bug in > CylindricalAlgebraicDecomposition (which is what InequalitySolve is > using): > > In[1]:= > << "Experimental`" > > In[2]:= > CylindricalAlgebraicDecomposition[x^6 - x^3 - 1 == 0 && > 0 < x < 2, x] > > Out[2]= > x == Root[-1 - #1^3 + #1^6 & , 2] > > In[3]:= > N[%] > > Out[3]= > x == 1.1739849967053284 > > Andrzej Kozlowski > Yokohama, Japan > http://www.mimuw.edu.pl/~akoz/ > http://platon.c.u-tokyo.ac.jp/andrzej/ > > > On Tuesday, November 12, 2002, at 05:13 PM, PSi wrote: > >> In[1]:= << Algebra`InequalitySolve` >> >> Example 1. >> >> In[2]:= N[InequalitySolve[x^5 - x^3 - 1 == 0 && 0 < x < 2, x] ] >> Out[2]:= x == 1.23651 >> >> Example 2. >> >> In[3]:= NSolve[x^6 - x^3 - 1 == 0, x] >> Out[3]:= {{x -> -0.8518}, {x -> -0.586992 - 1.0167 I}, >> {x -> -0.586992 + 1.0167 I }, {x -> 0.4259 - 0.73768 I}, >> {x -> 0.4259 + 0.73768 I}, {x -> 1.17398}} >> >> In[4]:= N[InequalitySolve[x^6 - x^3 - 1 == 0 && 0 < x < 2, x] ] >> >> Of course the answer should be x == 1.17398 as in the first example. >> Instead of >> this, Mathematica 4.1 for Windows gives the following: >> >> Greater::"nord" : "Invalid comparison with >> (-1)^(2/3)(1/2-Sqrt[5]/2)^(1/3) >> attempted. >> Less::"nord" : "Invalid comparison with >> -2+(-1)^(2/3)(1/2-Sqrt[5]/2)^(1/3) >> attempted. >> Out[4]:= x>0.&&x<2.&&x==-0.8518+3.88578*10^-16 I || x == 1.17398 >> >> Could anybody explain this? >> Thanks >> PSi >> >> >> >> >> >> >> >> >> >> >> >> >> >> >