Created
July 2, 2015 20:44
-
-
Save tetsu-miyagawa/bc05d9adce89b916fa7d to your computer and use it in GitHub Desktop.
SICP Section 1.1.8
This file contains 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-root x) | |
(define (good-enough? guess x) | |
(< (abs (- (square guess) x)) 0.001)) | |
(define (improve guess x) | |
(average guess (/ x guess))) | |
(define (sqrt-iter guess x) | |
(if (good-enough? guess x) | |
guess | |
(sqrt-iter (improve guess x) x))) | |
(sqrt-iter 1.0 x)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment