;;This program computes the cube root of a number. It also is in block structure
(define (cuberoot x)
(define (good-enough? guess)
(< (abs (- (cube guess) x)) 0.00000000001))
(define (cubert-iter guess)
(if (good-enough? guess)
guess
(cubert-iter (improve guess))))
(define (improve guess)
(/ (+ (/ x (* guess guess)) (* 2 guess)) 3))
(define (cube y) (* y y y))
(cubert-iter 1.0))
;;This program computes the cube root of a number. It also is in block structure
(define (cuberoot x)
(define (good-enough? guess)
(< (abs (- (cube guess) x)) 0.00000000001))
(define (cubert-iter guess)
(if (good-enough? guess)
guess
(cubert-iter (improve guess))))
(define (improve guess)
(/ (+ (/ x (* guess guess)) (* 2 guess)) 3))
(define (cube y) (* y y y))
(cubert-iter 1.0))
(define (cuberoot x)
(define (good-enough? guess)
(< (abs (- (cube guess) x)) 0.00000000001))
(define (cubert-iter guess)
(if (good-enough? guess)
guess
(cubert-iter (improve guess))))
(define (improve guess)
(/ (+ (/ x (* guess guess)) (* 2 guess)) 3))
(define (cube y) (* y y y))
(cubert-iter 1.0))
;;This program computes the cube root of a number. It also is in block structure
(define (cuberoot x)
(define (good-enough? guess)
(< (abs (- (cube guess) x)) 0.00000000001))
(define (cubert-iter guess)
(if (good-enough? guess)
guess
(cubert-iter (improve guess))))
(define (improve guess)
(/ (+ (/ x (* guess guess)) (* 2 guess)) 3))
(define (cube y) (* y y y))
(cubert-iter 1.0))
No comments:
Post a Comment