public final class NewtonExample {

   // Sqrt using Newton's method
   public static double sqrt (final double x) {
      assert x>=0;
      double t = 1.0D;  // a dumb guess
      for (;;) {
         // Improve the current guess, t, with a closer one
         final double t1 = (x/t + t) / 2.0;

         // Stop iterating when there is little improvement
         if (Math.abs (t1-t) < 1e-9) break;
         t = t1;
      }
      return t;
   }

   public static void main (final String[] args) {
      for (final String arg: args) {
         System.out.println (sqrt (Double.parseDouble (arg)));
      }
   }
}