Re: Re: Bug in NSolve?

*To*: mathgroup at smc.vnet.net*Subject*: [mg34002] Re: [mg33974] Re: Bug in NSolve?*From*: Andrzej Kozlowski <andrzej at platon.c.u-tokyo.ac.jp>*Date*: Fri, 26 Apr 2002 03:27:24 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

On Thursday, April 25, 2002, at 03:59 PM, Rodger Rosenbaum wrote: >> > > Andrzej Kozlowski suggests that when there is a root of multiplicity > greater than 1, we > should not be surprised if Mathematica only reports one root. In his > examples, we can > determine the multiplicity by inspection; but suppose we had a > polynomial of relatively > high order, say fifth degree, with, say, 2 distinct roots, and 1 of > multiplicity 3, e.g.: > > NSolve[x^5 - 15 x^4 + 74 x^3 - 142 x^2 + 117 x - 35,x,20] > > Mathematica gives: > {{ x--> 1.000000},{ x--> 1.000000},{ x--> > 5.00000000000000000},{x-->7.00000000000000000}} > > What am I to make of this? Why didn't Mathematica form the Union of > the three identical > roots and only show one? First of all, as I wrote in my message, you have to look at the answer in InputForm (or FullForm): In[1]:= NSolve[x^5-15 x^4+74 x^3-142 x^2+117 x-35,x,20]//InputForm Out[1]//InputForm= {{x -> 0.9999999999999999999`6.1651}, {x -> 1.`6.1651}, {x -> 5.`18.1471}, {x -> 7.`18.3392}} Usisng the given precision Mathematica sees four distinct roots. It did apply Union. Why it did not see that actually three roots (which are really 1's) are equal? Of course it is because of the way it computes them. (A trivial illusttration. Suppose you have a quadratic whose two equal roots satisfy a + b== 2 , so they are both 1. If Mathematica computes first a and makes an error of, say delta and then finds b from b== 2-a than a and b may now be sufficiently far to be considered distinct.) > Can I be sure that the root, 5, doesn't have multiplicity > greater than one? The lesser precision of the two roots, 1, implies > higher multiplicity > than the roots, 5 and 7, but but can I rely on such an inference? And > there is that claim > in the Mathematica Book: > > "NSolve will always give you the complete set of numerical solutions to > any > polynomial equation in one variable." This is indeed the complete *set* of solutions, within this precision. Note the word set, in mathematics this normally means that multiplicity is not counted. > > And here is some further peculiar behavior; try: > > NSolve[x^3 - 3 x^2 + 3 x - 1,x,20] > > NSolve[x^4 - 4 x^3 + 6 x^2 - 4 x + 1,x,20] > > These give two roots of unity, but if you remove the third argument > (the 20), then they > give 3 and 4 roots of unity, respectively. Make the third argument in > the cubic 25, and > get three roots of unity; make the third argument 200 and get only two > roots. > > and > > NSolve[x^5 - 5 x^4 + 10 x^3 - 10 x^2 + 5 x - 1,x,20] > > This gives 4 roots of unity; make the third argument 25 and get only 3 > roots. Make the > third argument 200, or 10000, and get two roots. > > > > This is not "further peculiar behaviour". Read my explanation again. One reason why NSolve behaves the way it does is that getting correct multiplicity in appraximate computations is tricky, particularly in the multivariate case. I have been told this behaviour will be changed in the future, but in any case, the answer you get will always only be correct to within the given precision. In other words, Mathematica will tell you that you have a double root when you in fact have two distinct rots very close together, or, when you have a double root it may tell you you have two distinct ones, unless you use sufficient precision. To get accurate multiplicity you must use Solve: In[4]:= Solve[x^5-15 x^4+74 x^3-142 x^2+117 x-35\==0,x]//InputForm Out[4]//InputForm= {{x -> 1}, {x -> 1}, {x -> 1}, {x -> 5}, {x -> 7}} Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/

**Re: Pattern matching**

**Re: Re: Pattern matching**

**Re: Bug in NSolve?**

**animations in mathematica**