(define (sqrt-iter guess x)
(if (good-enough? guess (improve guess x)) (improve guess x) (sqrt-iter (improve guess x) x)))(define (improve guess x)
(average guess (/ x guess)))(define (average x y)
(/ (+ x y) 2))(define (good-enough? old-guess new-guess)
(> 0.01 (/ (abs (- new-guess old-guess)) old-guess)))(define (sqrta x)
(sqrt-iter 1.0 x))(define (square x)
(* x x))(sqrta 0.00009)
不再检测猜测值 guess
的平方与 x
之间的差,而是检测新旧两次猜测值之间的比率,当比率变化非常小时,程序就停止 improve