[archives] [homepage]

Problem 1.36
Friday, August 23, 2019; ago; Download .md

SICP Exercise 1.36

Modified fixed-point procedure:

(define (fixed-point f first-guess)
  (define (close-enough? v1 v2)
    (display "x=")
    (display v1)
    (display " and f(x)=")
    (display v2)
    (< (abs (- v1 v2)) tolerance))
  (define (try guess)
    (let ((next (f guess)))
      (if (close-enough? guess next)
          (try next))))
  (try first-guess))

Without average damping:

> (fixed-point (lambda (x) (/ (log 1000) (log x))) 1.1)

This gives us the answer in 33 iterations.

With average damping:

> (fixed-point (lambda (x) (average x (/ (log y) (log x)))) 10.0)

This gives the answer in 10 iterations.