sicp-ex-3.79



<< Previous exercise (3.78) | Index | Next exercise (3.80) >>


meteorgan

  
  
 (define(general-solve-2nd f y0 dy0 dt) 
   (define y (integral (delay dy) y0 dt)) 
   (define dy (integral (delay ddy) dy0 dt)) 
   (define ddy (stream-map f dy y)) 
   y) 

The first argument to f should be dy/dt rather than dy. Therefore we have

  
 (define (solve-2nd-general f dt y0 dy0) 
   (define y (integral (delay dy) y0 dt)) 
   (define dy (integral (delay ddy) dy0 dt)) 
   (define ddy 
     (stream-map f 
                 (scale-stream dy (/ 1.0 dt)) 
                 y)) 
   y) 
  

dy is a reference to dy/dt. This is shown in the signal-processing diagram in the book.