Smoothing a Signal

A procedure smooth that takes as input a procedure that computes f and returns a procedure that computes the smoothed f.

Also implemented is a procedure that computes the n-fold smoothed function.

 

(define (cube x) (* x x x))
(define dx 0.00001)
(define (compose f g)
(lambda (x)
(f (g x))))
(define (repeated f n)
(if
(= n 1)
(lambda (x) (f x))
(compose f (repeated f (- n 1)))))
(define (smooth-once f)
(lambda (x)
(/
(+
(f (- x dx))
(f x)
(f (+ x dx)))
3)))
(define (smooth f n)
(repeated (smooth-once f) n))
view raw s144.scm hosted with ❤ by GitHub