20 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)

(define int

(cons-stream initial-value

(let ((integrand (force delayed-integrand)))

(add-streams (scale-stream integrand dt)

int))))

int)

(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))

y)

Subscribe to:
Post Comments (Atom)

## No comments:

Post a Comment