<< Previous exercise (1.43) | sicp-solutions | Next exercise (1.45) >>

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

The input needs only the function and the number of smoothing procedure, so it should not include x.

Be aware below is WRONG:

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

This is illustrated below for n=2

 ;; goal: n=2 -> "smooth the smoothed function" 
 ((repeated smooth 2) f) ;; -> smooth(smooth(f)) [Correct] 
 (repeated (smooth f) 2) ;; -> smooth(f(smooth(f)) [Incorrect]