Square roots by Newton’s method
问题 The following Scheme program implements Newton’s method for computing the square root of a number: (import (scheme small)) (define (sqrt x) (define (sqrt-iter guess) (if (good-enough? guess) guess (sqrt-iter (improve guess)))) (define (good-enough? guess) (define tolerance 0.001) (< (abs (- (square guess) x)) tolerance)) (define (improve guess) (if (= guess 0) guess (average guess (/ x guess)))) (define (average x y) (/ (+ x y) 2)) (define initial-guess 1.0) (sqrt-iter initial-guess))