MathGroup Archive 2006

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

Search the Archive

how many times nestwhile repeats calculations?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71944] how many times nestwhile repeats calculations?
  • From: Arkadiusz.Majka at gmail.com
  • Date: Tue, 5 Dec 2006 06:04:42 -0500 (EST)

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: Run option
  • Next by Date: Re: Making plots using transformation rules
  • Previous by thread: Re: Help finding x of hypergeometric 2F1[a,b,c,x] ?
  • Next by thread: Re: how many times nestwhile repeats calculations?