Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: NestWhile iterator.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg66534] Re: NestWhile iterator.
  • From: "Ray Koopman" <koopman at sfu.ca>
  • Date: Fri, 19 May 2006 03:39:37 -0400 (EDT)
  • References: <e4bivp$1ap$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

I too remember seeing the post you're talking about but don't remember
its subject, so here's a routine that counts the Newton iterations for
a square root.

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}


  • Prev by Date: Re: Extract any diagonal from a square matrix...
  • Next by Date: Re: what is K$
  • Previous by thread: NestWhile iterator.
  • Next by thread: Re: NestWhile iterator.