Blob


1 (define (cbrt x)
2 (cbrt-iter 1.0 x))
4 (define (cbrt-iter guess x)
5 (if (good-enough? guess x)
6 guess
7 (cbrt-iter (improve guess x) x)))
9 (define (good-enough? guess x)
10 (< (abs (- (cube guess) x)) 0.001))
12 (define (improve guess x)
13 (/ (+ (/ x (square guess)) (* 2 guess)) 3))
14 (define (square x) (* x x))
15 (define (cube x) (* x x x))
17 (cbrt 15)
18 ;; 2.46621207
19 (cbrt 8)
20 ;; 2
21 (cbrt 64)
22 ;; 4