Note that there are some explanatory texts on larger screens.

plurals
  1. POIs this a bug in NSolve in mathematica?
    text
    copied!<p>One would expect and hope that if you ask <code>Mathematica</code> 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 <code>Mathematica 7</code>, running on OS X) where this fails badly:</p> <pre><code>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]]] </code></pre> <p>(Note: this is actually a Laurent polynomial, and if you multiply through by a large power of <code>q</code> the problem goes away.)</p> <p>The last line here is just a demonstration that the solutions found are very different; in fact it's the quantity we were trying to compute in the problem we were working on.</p> <p>If you look closely at the output of <code>NSolve[poly == 0, q]</code> and of <code>N[Solve[poly == 0, q]</code>, you'll see that NSolve only gives <code>54</code> roots instead of the expected <code>56</code>. It's not that it just missed a repeated root or anything; it's missing the two largest roots in magnitude (approximately <code>+/- 1.59</code>)</p> <blockquote> <p>Is this a bug in Mathematica? Does anyone have an explanation for why this is happening?</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload