View Single Post
  #10  
Old September 21st, 2004, 10:20 PM
Jack Simth's Avatar

Jack Simth Jack Simth is offline
Major General
 
Join Date: Oct 2002
Posts: 2,174
Thanks: 0
Thanked 0 Times in 0 Posts
Jack Simth is on a distinguished road
Default Re: OT: Interesting math problem...

Narf: I don't know of any cut and dry equation for finding a square root - however, there is a reasonably simple recursive method for approximating a square root to any precision desired:

R(0, N) = N
R(k, N)) = (N/R(k - 1, N) + R(k - 1, N))/2

DO NOT DO THIS RECURSIVLY - run it as a loop, saving the Last value.
Where N is the original number (constant), and k is a method to control the precision.
A sample: N = 16

Root(0, 16) = 16;
Root(1, 16) = (16/16 + 16)/2 = (1 + 16) / 2 = 8.5
Root(2, 16) = 5.1911764...
Root(3, 16) = 4.1366647...
Root(4, 16) = 4.0022575...
Root(5, 16) = 4.0000006...
Root(6, 16) = 4.0000000...

As you can see, it gets there farily quickly.
__________________
Of course, by the time I finish this post, it will already be obsolete. C'est la vie.
Reply With Quote