Exercise 1.36
(define tolerance 0.00001)
(define (close-enough? x y) (< (abs (- x y)) tolerance))
(define (fixed-point-verbose f first-guess)
(define (try guess)
(let ((next (f guess)))
(display next)
(newline)
(if (close-enough? guess next)
next
(try next))))
(try first-guess))
(define (f x) (/ (log 1000) (log x)))
Without average damping, it takes 28 approximations.
(hide-output (fixed-point-verbose f 5)) ~> 4.555539314360711
(string-count #\newline (capture-output (fixed-point-verbose f 5))) => 28
With average damping, it takes only 8 approximations.