* 1.1.7 Square Roots by Newton's Method

#+BEGIN_SRC scheme :session sqrt :noweb yes

  (define (sqrt-iter guess x)
    (if (good-enough? guess x)
	guess
	(sqrt-iter (improve guess x)
		   x)))
  (define (square x)
    (* x x))
  (define (improve guess x)
    (average guess (/ x guess)))
  (define (average x y)
    (/ (+ x y) 2))
  (define (good-enough? guess x)
    (< (abs (- (square guess) x)) 0.001))
  (define (sqrt x)
    (sqrt-iter 1.0 x))
  (sqrt 25)

#+END_SRC

#+RESULTS:
: 5.000023178253949

#+BEGIN_SRC scheme :session sqrt

  (square (sqrt 1000))

#+END_SRC

#+RESULTS:
: 1000.000369924366
