Re: Is this a bug in NSolve in mathematica?
- To: mathgroup at smc.vnet.net
- Subject: [mg113247] Re: Is this a bug in NSolve in mathematica?
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Wed, 20 Oct 2010 04:09:12 -0400 (EDT)
On 10/19/10 at 5:55 AM, scott.morrison at gmail.com (Scott Morrison) wrote: >One would expect and hope that if you ask Mathematica to find the >roots of a polynomial, it should give the same (approximate) answers >whether you do this symbolically, then find numerical approximations >to these exact answers, or whether you do it numerically. Here's an >example which (in Mathematica 7, running on OS X) where this fails >badly: >-------------------------------------------------------------------- >------------------------------------------- ------------ poly = -112 >+ 1/q^28 + 1/q^26 - 1/q^24 - 6/q^22 - 14/q^20 - 25/q^18 - >38/q^16 - 52/q^14 - 67/q^12 - 81/q^10 - 93/q^8 - 102/q^6 - 108/ q^4 >- 111/q^2 - 111 q^2 - 108 q^4 - 102 q^6 - 93 q^8 - 81 q^10 - 67 q^12 >- 52 q^14 - 38 q^16 - 25 q^18 - 14 q^20 - 6 q^22 - q^24 + q^26 + >q^28; >Total[q^4 /. NSolve[poly == 0, q]] - Total[q^4 /. N[Solve[poly == 0, >q]]] First, doing, NSolve[...] is should not be assumed equivalent to N[Solve[....]]. Assuming these are the same makes assumptions about how things are being converted to machine precision. It can make a difference if coefficients are made machine precision then the problem is solved or the exact solution is converted to machine precision. It is easy to see the issue is one of machine precision as follows: In[6]:= Chop[ Total[q^4 /. NSolve[poly == 0, q]] - Total[q^4 /. N[Solve[poly == 0, q]]]] Out[6]= -12.8547 In[7]:= Chop[ Total[q^4 /. NSolve[poly == 0, q, WorkingPrecision -> 50]] - Total[q^4 /. N[Solve[poly == 0, q], 50]]] Out[7]= 0 That is simply increasing the working precision makes the discrepancy disappear.