MathGroup Archive 1999

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

Search the Archive

Re: Algorithms to calculate square root

  • To: mathgroup at smc.vnet.net
  • Subject: [mg16498] Re: [mg16454] Algorithms to calculate square root
  • From: BobHanlon at aol.com
  • Date: Tue, 16 Mar 1999 03:59:48 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

In a message dated 3/13/99 12:13:34 PM, ajith.pn at pcm.bosch.de writes:

>This question is about the calculation of square root using numerical
>analytical algorithms. I found the formula  (from  the book  "Numerical
>Recipes in C - The Art of Scientific Computing" )  
>	
>	if 
>	U[i+1]	=  0.5 *  U[i]  * (   3 - V * U[i] * U[i]  )	
>then U[infinity] converges quadratically to 1/sqrt(V). A final
>multiplication by V gives sqrt(V).
>
>Are there any other similar algorithm to calculate square root?
>

Ajith,

I don't have Knuth's book handy, but I believe this algorithm is in it:

For y = Sqrt[x], y[n] = (y[n-1] + x/y[n-1])/2

y[n_Integer?Positive, x_?Positive] := NestList[((# + x/#)/2.)&,x, n]
(* If you only want the final result, 
		use Nest vice NestList *)

y[5, 16]

{16,8.5,5.19118,4.13666,4.00226,4.}

Bob Hanlon


  • Prev by Date: combinations of pure functions
  • Next by Date: Normalize a vector ????
  • Previous by thread: Algorithms to calculate square root
  • Next by thread: Re: Select in Math.