3 [clojure.contrib trace test-is]))
5 ;; exercise 1.8: cube root
6 (defn improve [guess x]
7 (/ (+ (/ x (square guess)) (* 2 guess)) 3))
9 (defn cubert-iter [old-guess new-guess x]
10 (if (good-enough? old-guess new-guess x)
12 (cubert-iter new-guess (improve new-guess x)
16 (cubert-iter x 1.0 x))
19 user> (cuberoot (cube 2))
21 user> (cuberoot (cube 10))
23 user> (cuberoot (cube 9))
25 user> (cuberoot (cube 0.001))
27 user> (cuberoot (cube 0.0001))