SICP习题 1.8 (立方根)

(define (cube-root x)
(cube-root-iter 1.0 x))

(define (cube-root-iter guess x)
(if (good-enough? guess x)
guess
(cube-root-iter (improve guess x)
x)))

(define (good-enough? guess x)
(< (abs (- (* guess guess guess) x))
0.001))

(define (improve guess x)
(/ (+ (/ x (* guess guess)) (* 2 guess)) 3))

(cube-root (* 3 3 3))

posted @ 2017-11-22 19:01  R4mble  阅读(222)  评论(0编辑  收藏  举报