牛顿法计算立方根
#lang racket
;cube root
(define (cube-root x)
(cube-iter 1.0 x)
)
(define (cube-iter guess x)
(if (good-enough? guess x)
guess
(cube-iter (improve guess x) x)
)
)
(define (improve guess x)
(get-result guess x)
)
(define (get-result x y)
(/ (+ (/ y (* x x)) (* 2 x)) 3)
)
(define (good-enough? guess x)
(< (abs (- (* guess guess guess) x)) 0.0001)
)