MathGroup Archive 2004

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

Search the Archive

Re: Re: Beware of NSolve - nastier example

  • To: mathgroup at
  • Subject: [mg50432] Re: [mg50414] Re: Beware of NSolve - nastier example
  • From: DrBob <drbob at>
  • Date: Fri, 3 Sep 2004 03:35:32 -0400 (EDT)
  • References: <> <cg6srb$odf$> <> <> <> <ch3olv$33$> <>
  • Reply-to: drbob at
  • Sender: owner-wri-mathgroup at

I was iterating to 50 digit answers with starting points from 1/3 to 4 times the correct root. You're getting a machine precision answer with a start that's already correct to 13 places. The difference between the converged answer and your starting value, in fact, was


It's not surprising you could get convergence starting there. If you say the convergence interval is +/-10^-1, OK, but that's awfully close for an initial guess!!

However, I was very far off in my post. I should have had

g[x_]:=x - f[x]/f'[x]

This is exactly what you were doing, and what I thought I was doing, but wasn't!

Now, the derivative at the machine precision and 50-digit solutions are:



And that's very nice! But at other nearby points:



If that norm is greater than one anywhere on the interval between the desired root and the starting point, then g isn't a contraction, and convergence of the basic NR is very iffy.


On Thu, 2 Sep 2004 04:34:54 -0400 (EDT), Carlos Felippa <carlos at> wrote:

> DrBob <drbob at> wrote in message news:<ch3olv$33$1 at>...
>> Oops, in my last paragraph I claimed convergence for a wider range of starting values than I actually get. (I had a typo when doing some of the tests.) 0.003`n to 0.04`n looks fine. At least it converges for SOME input, which is more than the raw Newton iteration can do.
>> Of course, I used Solve to get the h function--the same Solve routine that solved the original problem already!
> No problem whatsoever for conventional NR in 16-digits
> (double precision) if you are sufficiently near a root.  Just run this
> NR iteration, which is at the level of the homeworks I assign to
> engineering sophomores:
> ClearAll[f,x];
> f=(5/432-11/(27*Sqrt[70]*Sqrt[19-1890*x])+x/(2*Sqrt[38/35-(108+1/10000000)*x]));
> fprime=D[f,x];
> Print[N[Solve[f==0,x]]//InputForm];  (* gives 3 correct roots *)
> SetPrecision[{xn,xnext,r,f,fprime,fp},16];
> xn=0.0100529100415;  (* the slippery root *)
> n=10;   (* actually n=3 is enough  to get limit accuracy *)
> For [i=1,i<=n,i++, r=N[f/.x->xn]; fp=N[fprime/.x->xn];
>      dx=-r/fp; xnext=xn+dx;
>      Print[{i,r,fp,dx,xn,xnext}//InputForm]; xn=xnext];
> The derivative f' is large, O(10^13) whereas the residual goes down to
> O(10^(-4)). The interval where NR converges to that root is tiny, of
> O(10^(-10), but finite.  If one tries single precision (~ 6-7 digits)
> NR fails, as noted by Daniel Lichtblau,  since the convergence
> interval falls in the noise.
> What  is a bit surprising to me is that NSolve applied directly to f,
> (not as N[Solve][..]]) needs 128-digit working precision to resolve
> that root.

DrBob at

  • Prev by Date: Re: Re: newbie is looking for a customDistribution function
  • Next by Date: Re: Sorting (again!), but with multiple columns
  • Previous by thread: Re: Beware of NSolve - nastier example
  • Next by thread: Re: Re: Beware of NSolve - nastier example