MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Beware of NSolve - nastier example

  • To: mathgroup at
  • Subject: [mg50220] Re: [mg50207] Beware of NSolve - nastier example
  • From: Daniel Lichtblau <danl at>
  • Date: Sat, 21 Aug 2004 03:04:23 -0400 (EDT)
  • References: <>
  • Sender: owner-wri-mathgroup at

Carlos Felippa wrote:
> This is a nasty one:
> f=5/432-11/(27*Sqrt[70]*Sqrt[19-1890*x])+x/(2*Sqrt[38/35-(108+1/10000000)*x]);
> Print[N[Solve[f==0,x]]]; (* OK, 3 roots #2,4,5 of a sextic poly *)
> Print[NSolve[f,x,16]];   (* 6 roots, 3 wrong *)
> Print[NSolve[f,x,21]];   (* 4 roots, 2 correct, 1 double wrong, 
>         1 single wrong *)
> Print[NSolve[f,x,24]];   (* 3 roots, 1 wrong *)
> Print[NSolve[f,x,28]];   (* 3 roots, 1 wrong *)
> Print[NSolve[f,x,32]];   (* 2 correct roots, missed 1 *)
> Print[NSolve[f,x,64]];   (* 2 correct roots, missed 1 *)
> Print[NSolve[f,x,128]];  (* 3 correct roots  *)
> All 3 roots are single and well conditioned, no problem getting them
> in single precision with NR.
> Note: please reply to this newsgroup; DONT send mail to me directly
> (there is a white list, if not in list  your msg >null)

The claim that all roots are well conditioned is not correct. One of 
them is quite problematic.

Look at all six solutions, including parasites, to the Solve (do this 
via VerifySolutions->False). You will see that there is very nearly, but 
not exactly, a double root. This means NSolve will, at modest precision, 
be forced to decide the thing is a double root, average the values, and 
get somenthing that is not in fact a correct solution. The verification 
process will then discard this. To make matters worse, the two agree to 
about 15 digits, and moreover agree with a root of something in a 
denominator to about 11 digits. So far as I can tell any numeric 
polynomial solver is going to be in for a difficult time with this, 
because near such a denominator residuals can fluctuate wildly.

On the flip side, the heuristics that decide when a root actually 
satisfies the equation can be a bit lax. Hence parasites can wind up in 
the returned solution set. One way to influence this is to rescale the 
equation e.g. multiplying by some large number.

I'll look into tightening some of the decisions as to what constitutes a 
sufficiently small residual. The near-double-root issue goes with the 
territory and is in no way incorrect behavior.

What is NR, by the way?

Daniel Lichtblau
Wolfram Research

  • Prev by Date: Re: Label of Max[list]
  • Next by Date: Re: Re: Re: FindMinimum and the minimum-radius circle
  • Previous by thread: Re: Beware of NSolve - nastier example
  • Next by thread: Re: Beware of NSolve - nastier example