Re: Re: Change in NSolve algorithm
- To: mathgroup at smc.vnet.net
- Subject: [mg98593] Re: [mg98545] Re: Change in NSolve algorithm
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Mon, 13 Apr 2009 03:37:01 -0400 (EDT)
- References: <grpif7$lnr$1@smc.vnet.net> <200904120747.DAA27216@smc.vnet.net>
On 12 Apr 2009, at 16:47, ADL wrote: > What surprised me about Wilkinson's polynomial example, which should > return Range[20], is the following. > > Mathematica Help says that: "NSolve[eqns,vars,n] gives results to n- > digit precision". Consequently, omitting n should imply machine > precision. Nevertheless: > > sols = x /. NSolve[Expand[Product[x - i, {i, 1, 20}] == 0, x], x] > > {1 > ., > 2.00000000000096,2.99999999986639,4.0000000049587,4.99999990255529,6.00 > = > 000083841557+1.13297570609149*10^-9 > I,7.00008136819274-0.0000108589979212047 I, > 8.00087475000192+0.000151959812492809 I, > 9.0002388679906+0.000147736991612302 I, > 10.000992367067-0.000579336748622785 I, > 11.0030045370741-0.00438286449628658 I, > 12.0383486261734-0.102068022121597 I, > 13.1275500318654+0.0361732078353353 I, > 13.9803341855889+0.0168546889387958 I, > 14.9015299203113-0.0418410427904214 I, > 15.8215727528799+0.0440619301323384 I, > 16.9944217046715-0.00669060159139528 I, > 18.0000979553809-0.000170510501593321 I, > 18.999972121053+0.00014011316501936 I, > 19.9999979459428+1.38662076005353*10^-6 I} > > while > > sols = x /. NSolve[Expand[Product[x - i, {i, 1, 20}] == 0, x], x, > $MachinePrecision] > {1.000000000000000,2.000000000000000,3.000000000000000,4.000000000000000,5 > .= > 000000000000000,6.000000000000000,7.000000000000000,8.000000000000000,9.000 > = > 000000000000,10.00000000000000,11.00000000000000,12.00000000000000,13.00000 > = > 000000000,14.00000000000000,15.00000000000000,16.00000000000000,17.00000000 > = > 000000,18.00000000000000,19.00000000000000,20.00000000000000} > > Even with 2 digits precision the result is correct! > > sols = x /. NSolve[Expand[Product[x - i, {i, 1, 20}] == 0, x], x, 2] > {1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10 > .,11.,12.,13.,14.,15.,16.,17.,18.,19= > .,20.} > > So, I would say that your example indicates a misbehavior or a bug in > NSolve. > > Any comments? Yes. $MachinePrecision is not the same as MachinePrecision. Try the latter and see what happens. Andrzej Kozlowski > > > Alberto > > > On 11 Apr, 09:56, mark mcclure <mcmcc... at unca.edu> wrote: >> Has anyone noticed that the algorithm used by NSolve has >> changed in V7? >> ... >> On the other hand, V7 fares slightly worse with Wilkinson's >> polynomial: >> sols = x/.NSolve[Expand[Product[x-i, {i,1,20}] == 0,x]]; >> Norm[Table[sols[[i]] - i, {i, 1, 20}]] >> ... >> Mark McClure > >
- References:
- Re: Change in NSolve algorithm
- From: ADL <alberto.dilullo@tiscali.it>
- Re: Change in NSolve algorithm