4 hours ago
my attempt to do the exercises in sicp.
Tuesday, January 4, 2011
sicp exercise 3.79
;; Exercise 3.79. Generalize the solve-2nd procedure of exercise 3.78 so that it can be used to solve general second-order differential equations d2 y/dt2 = f(dy/dt, y).
(define (integral delayed-integrand initial-value dt)
(let ((integrand (force delayed-integrand)))
(add-streams (scale-stream integrand dt)
(define (solve f y0 dy0 dt)
(define y (integral (delay dy) y0 dt))
(define dy (integral (delay ddy) dy0 dt))
(define ddy (stream-map f y dy))