Exercise 1.7: (back)


The good-enough? test produces very inaccurate results for very small numbers.  For example,
calculating the square root of 0.0001 would result in an answer of 0.01. However, running
the sqrt function gives a result that is ~3.2 times larger than the correct result.
> (sqrt 0.0001) 0.03230844833048122 Testing for very large numbers (e.g. see below) produces a slightly different problem, in
that the operation never terminates. This is due the good-enough? function being unable to
guess large numbers to a precision of 0.001.
> (sqrt 1e15) Error: Never Terminates


Alternative Version 1:
(define (good-enough? guess x)
  (< (/ (abs (- (improve guess x) guess)) guess) 0.001))

Alternative Version 2:
(define (good-enough? guess x)
      (< (abs (/ (improve guess x) guess)) 1.001)
      (> (abs (/ (improve guess x) guess)) 0.999))
    [else false]))