chickadee » sicp » euler-transform

euler-transform sprocedure

Applies Euler's transform, i.e. a linear sequence transformation for improved convergence, to a stream.

s
The stream to which to apply Euler's transform
(define (euler-transform s)
  (let ((s0 (stream-ref s 0)) (s1 (stream-ref s 1)) (s2 (stream-ref s 2)))
    (cons-stream
      (- s2 (/ (square (- s2 s1)) (+ s0 (* -2 s1) s2)))
      (euler-transform (stream-cdr s)))))