我编写了这段代码来计算方案中数字的立方根
(define (square x) (* x x))
(define (abs x) (if (< x 0) (- x) x))
(define (cube x) (* x x x))
(define (cube-root-itr guess x) (if (good-enough? guess x) guess (cube-root-itr (improve guess x) x)))
(define (improve guess x) (/ (+ (* 2 guess) (/ x (square guess))) 3))
(define (good-enough? guess x) (< (abs (- (cube guess) x)) 0.0000000001))
(define (cube-root x) (cube-root-itr 1.0 x))
(cube-root 9)
返回:2.080083823051904>
为什么它不返回更精确的答案?我怎样才能让它变得更好?这是 SICP 书中的练习 1.8
这个程序完全正确,返回的值确实是9的立方根,或者尽可能接近。