[Date Index]
[Thread Index]
[Author Index]
Re: Re: Beware of NSolve - nastier example
*To*: mathgroup at smc.vnet.net
*Subject*: [mg50432] Re: [mg50414] Re: Beware of NSolve - nastier example
*From*: DrBob <drbob at bigfoot.com>
*Date*: Fri, 3 Sep 2004 03:35:32 -0400 (EDT)
*References*: <200408200858.EAA12533@smc.vnet.net> <cg6srb$odf$1@smc.vnet.net> <200408280837.EAA19074@smc.vnet.net> <200408311028.GAA18653@smc.vnet.net> <opsdluzdvziz9bcq@monster.cox-internet.com> <ch3olv$33$1@smc.vnet.net> <200409020834.EAA02117@smc.vnet.net>
*Reply-to*: drbob at bigfoot.com
*Sender*: owner-wri-mathgroup at wolfram.com
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
-3.189115638235762*^-14
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:
g'@single
g'@fifty
8.942337077226623*^-7
0``39.84918837339986
And that's very nice! But at other nearby points:
g'/@Range[.005,.015,.001];
Norm/@%
{0.611662,0.832022,1.05746,1.32013,1.6874,2.63267,2.89968,2.80032,2.70822,2.\
62331,2.54518}
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.
Bobby
On Thu, 2 Sep 2004 04:34:54 -0400 (EDT), Carlos Felippa <carlos at colorado.edu> wrote:
> DrBob <drbob at bigfoot.com> wrote in message news:<ch3olv$33$1 at smc.vnet.net>...
>> 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 bigfoot.com
www.eclecticdreams.net
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**
| |