Created
February 20, 2015 05:03
-
-
Save kouddy/be126eb637da5816bba2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (square x) (* x x)) | |
(define (improve guess x) | |
(/ (+ (/ x (square guess)) (* 2 guess)) 3)) | |
(define (good-enough? guess improved-guess x) | |
(< (/ (abs (- guess improved-guess)) guess) 0.001)) | |
(define (cubic-root-iter guess x) | |
(if (good-enough? guess (improve guess x) x) | |
guess | |
(cubic-root-iter (improve guess x) x))) | |
(define (cubic-root x) | |
(cubic-root-iter 1.0 x)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment