<< Previous exercise (3.77) | Index | Next exercise (3.79) >>
; Some test cases to verify an implementation.. (stream-ref (solve-2nd 1 0 0.0001 1 1) 10000) ; e (stream-ref (solve-2nd 0 -1 0.0001 1 0) 10472) ; cos pi/3 = 0.5 (stream-ref (solve-2nd 0 -1 0.0001 0 1) 5236) ; sin pi/6 = 0.5
I had the same solution has meteorgan and the program runs out of memory when trying to solve anything. I have memory limit to 1GB as well
Don't we want to handle the subtraction in the equation at some point?
Something like:
(define (solve-2nd a b dt y0 dy0)
(define y (integral (delay dy) y0 dt))
(define dy (integral (delay ddy) dy0 dt))
(define ddy (add-stream
(scale-stream dy (- a))
(scale-stream y (- b))))
y)
I don't know math well enough to know the answer. I've been searching across the internet looking for an example, but everybody uses the same answer as meteorgan.
Just wondering if anybody know why.
(define (solve-2nd a b dt y0 dy0) (define y (integral (delay dy) y0 dt)) (define dy (integral (delay ddy) dy0 dt)) (define ddy (add-streams (scale-stream dy a) (scale-stream y b))) y)