牛顿法求三次方根

(define (cube x)
  (* x (* x x)))
(define (square x)
  (* x x))
(define (my-sqrt3 x)
  (sqrt3-iter 1.0 x))
(define (sqrt3-iter guess x)
  (if (good-enough? guess x)
      guess
      (sqrt3-iter (improve guess x) x)))
(define (good-enough? guess x)
  (< (abs(- (cube guess) x)) 0.001))
(define (improve y x)
  (/ (+ (/ x (square y)) (* 2 y)) 3))
  

你可能感兴趣的:(SICP)