// -*- mode: java; -*- // Newtons approximation to the square root val _test_sqrt = { flt x -> flt epsilon = 1e-15; flt guess = x; while( 1 ) { flt next = (x/guess + guess)/2; if( guess-epsilon <= next & next <= guess+epsilon ) return guess; //if( guess==next ) return guess; guess = next; } }; flt farg = arg; return _test_sqrt(farg) + _test_sqrt(farg+2.0);