MathGroup Archive 2006

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

Search the Archive

Re: how many times nestwhile repeats calculations?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71964] Re: how many times nestwhile repeats calculations?
  • From: "dimitris" <dimmechan at yahoo.com>
  • Date: Wed, 6 Dec 2006 06:03:47 -0500 (EST)
  • References: <el3k8b$r61$1@smc.vnet.net>

Use NestWhileList

FrontEndExecute[{HelpBrowserLookup["MainBook","NestWhileList"]}]

or

http://documents.wolfram.com/mathematica/functions/NestWhileList

Also there is relevant material in Alan Hayes's How and Why column.
You can download it here:

http://library.wolfram.com/infocenter/Articles/3162/

Regards
Dimitris

Arkadiusz.Majka at gmail.com wrote:
> Hi,
>
> >From Help Browser we read
>
> NestWhile[f, expr, test] starts with expr, then repeatedly applies f
> until applying test to the result no longer yields True.
>
> I would like to know how many times f is applied till test stops
> everything. I read already a post in which the following example was
> presented
>
> In[1]:= mysqrt[a_] := NestWhile[{#[[1]]+1, .5(#[[2]]+a/#[[2]])}&,
>                                 {0, Max[1.,N@a]}, #[[2]]^2 > a&]
> In[2]:= mysqrt[2]
> Out[2]= {5, 1.41421}
>
>
> Do you know any other method? I don't want to influence to NestWhile
> (by inserting a "counting" element #[[1]]+1 )
> 
> Thanks,
> 
> Arek


  • Prev by Date: Re: how many times nestwhile repeats calculations?
  • Next by Date: Re: Making plots using transformation rules
  • Previous by thread: Re: how many times nestwhile repeats calculations?
  • Next by thread: Re: Area of ellipse between major axis and ray through focus, given angle