While Statement II

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]

Heron.java
      root = 1.0; lroot = x;
      while (Math.abs(root - lroot) > epsilon) {
         lroot = root;
         root = (root + x / root) / 2.0;
      }

*Heron (ca. 10-75 AD) described in his Metrica following method to compute the square root of a real-valued x:

1.Initialization: x1   =   1
 
2.Iteration:
xn+1 =
xn +
x

xn

2

 
3.Repeat step 2 until | xn+1   -   xn |   <   epsilon where epsilon is the desired precision.
 

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]
Copyright © 2001, 2002 Andreas Borchert, converted to HTML on February 11, 2002