3 ms·
Just out of curiosity, what's the advantage of `(2/x + x)/2` over `x/2 + 1/x` (which, to me, is more readable)?
by JadeNB 16y ago
Just out of curiosity, what's the advantage of `(2/x + x)/2` over `x/2 + 1/x` (which, to me, is more readable)?
- eru 16y agoIt is more readable. But I wanted to stick close to the general formula [1], so that you see what's going on. It would probably have been better to write it as: y = 2 average x1 x2 = (x1 + x2) / 2 next x = average (y/x + x) It's just a co-incidence that I chose y as 2. [1] Heron's Method (http://en.wikipedia.org/wiki/Herons_method#Babylonian_method http://en.wikipedia.org/wiki/Herons_method#Babylonian_method)