sicp-ex-1.44


 (define dx 0.00001) 
  
 (define (smooth f) 
   (lambda (x) 
     (/ (+ (f (- x dx)) 
           (f x) 
           (f (+ x dx))) 
        3))) 
  
 (define (n-fold-smooth f n) 
   ((repeated smooth n) f)) 

The above answer for n-fold-smooth is incorrect. The function "repeated" is not used correctly in the function. Repeated should be defined as:

 (define (repeated f n) 
   (lambda (x) (cond ((= n 0) x) 
                     (else 
                      ((compose (repeated f (- n 1)) f) x))))) 

And n-fold-smooth (named "n-smooth" below) should be defined as:

 (define (n-smooth f n x) 
   ((repeated (smooth f) n) x)) 

<< Previous exercise (1.43) | Next exercise (1.45) >>