-
-
Save redsquirrel/190711 to your computer and use it in GitHub Desktop.
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 (good-enough? guess x) | |
(< (abs (- (square guess) x)) 0.001)) | |
;; The good-enough? test used in computing square roots will not be | |
;; very effective for finding the square roots of very small numbers. Explain. | |
;; | |
;; good-enough? is not effective for small numbers because the square | |
;; of a small number minus the number quickly becomes less than 0.001. | |
(sqrt 0.00001) | |
=> .031356 | |
;; correct answer is 0.003162 | |
;; Also, in real computers, arithmetic operations are almost always | |
;; performed with limited precision. This makes our test inadequate | |
;; for very large numbers. Explain. | |
;; | |
;; good-enough? is not effective for very large numbers because the lack | |
;; of precision prevents the difference between the two numbers from ever | |
;; getting small enough. | |
(sqrt 100000000000000000000000000000000000000000000000000000000000000000) | |
=> NEVER RETURNS | |
;; correct answer is 3.16227766016838e+32 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment