Re: Bug in NSolve?

*To*: mathgroup at smc.vnet.net*Subject*: [mg33820] Re: [mg33788] Bug in NSolve?*From*: Andrzej Kozlowski <andrzej at tuins.ac.jp>*Date*: Fri, 19 Apr 2002 02:27:40 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

Unlike Solve, NSolve returns only one root when it finds multiple roots it considers to be sufficiently close to be identical. In fact it seems that it applies Union to the final result. So when you use more precision the roots which were considered as distinct due to possible error become identified and appear only once. Here are some examples, which I think make it clear: In[1]:= NSolve[x^2-2x+1==0,x] Out[1]= {{x -> 0.9999999999999998}, {x -> 1.0000000000000002}} Note that the roots are considered as distinct. However, In[2]:= NSolve[(x - 1)*(x - 1) == 0, x] Out[2]= {{x -> 1.}} Now you see only one root. Actually of course Mathematica found two, but it realized that they are equal. If you use the unfactored form of input but increase precision this is what happens. With working precision <= 20 we get: In[3]:= NSolve[x^2 - 2*x + 1 == 0, x, 23] Out[3]= {{x -> 0.9999999999999997779553937032`11.0773}, {x -> 1.0000000000000000035245156918`11.0773}} but In[4]:= NSolve[x^2 - 2*x + 1 == 0, x, 24] Out[4]= {{x -> 1.`11.5778}} The same thing happens in your case. Just look at your outputs using InputForm to see the hidden digits. Why do Solve and NSolve behave differently here? Well, it seems to me that it is probably a matter of "philosophy". Solve is basically an "algebraic function" and from the algebraic point of view the multiplicity of roots is an important property of a solution. But most people looking for numerical solutions would be I think inclined to consider multiple roots as "the same". There may be also a more subtle or a much simpler explanation but I guess that has to come from someone intimately involved in the design of these functions. Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/ On Tuesday, April 16, 2002, at 04:50 PM, rodgerroSPAMNOT.siteconnect.com at library2.airnews.net wrote: > The Mathematica book says in section 2.9.5: > > "NSolve will always give you the complete set of numerical solutions to > any > polynomial equation in one variable." > > However, Mathematica version 4.1.2 on a Pentium III gives this result: > > NSolve[4877361379 x^2 -9754525226 x + 4877163849==0,x,20] > > {{ x---> 0.9999797501 }} > > On the other hand, > > NSolve[4877361379 x^2 -9754525226 x + 4877163849==0,x,10] > > gives: > > {{ x ---> 0.99998 } , { x---> 0.99998 } } > > Machine precision works, but arbitrary precision doesn't? > > At least now we get two roots; the correct solution is given by: > > N[Solve[4877361379 x^2 -9754525226 x + 4877163849==0,x ] ,10] > > which is: > > {{ x ---> 0.99998 - 2.89955 x 10^-10 i },{ x---> 0.99998 + 2.89955 x > 10^-10i }} > > Does anybody know what's going on here? > > > > >