这种方法也叫巴比伦算法
python代码如下
import math
num = int(raw_input("input your number:"))
tolerance = float(raw_input('input your tolerance:'))
guess = num / 2.0
while math.fabs(guess ** 2 - num) > tolerance:
guess = (guess + (num / guess)) / 2.0
print 'sqrt of',num,'is',guess