Re: NestWhile iterator.

*To*: mathgroup at smc.vnet.net*Subject*: [mg66558] Re: NestWhile iterator.*From*: "Borut Levart" <BoLe79 at gmail.com>*Date*: Sat, 20 May 2006 04:46:56 -0400 (EDT)*References*: <e4bivp$1ap$1@smc.vnet.net><e4jtlq$cuq$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Hey, that's an elegant solution. Since calculating the square root above is very ... definite, I remembered something "off-topic" and wanted to try out: how would one compare the last two result of NestWhile in order to stop the calculation? With supplying the fourth argument to the function. With counting the iterations, let's solve for the intersection of y = cos(x) and y = x with an error tolerance of 0.001: In[13]:= NestWhile[{#[[1]]+1,Cos[#[[2]]]}&, {0,.5}, Abs[#1[[2]]-#2[[2]]]>.001&, 2] Out[13]= {16, 0.738705} Bye, Borut Levart Slovenia