ruandao / blog

0 stars 0 forks source link

[12.24] [sicp 3.65] #115

Closed ruandao closed 8 years ago

ruandao commented 8 years ago
(load "stream.scm")

(define (negative-series s)
  (cons-stream (- (stream-car s))
           (negative-series (stream-cdr s))))
(define (ln2 n)
  (cons-stream (/ 1 n)
           (negative-series (ln2 (+ n 1)))))

#|

 (stream-head 'ln2 (ln2 1) 10)

|#
ruandao commented 8 years ago

(load "stream.scm")
(load "stream-euler.scm")

(define (negative-series s)
  (cons-stream (- (stream-car s))
           (negative-series (stream-cdr s))))
(define (ln2 n)
  (cons-stream (/ 1.0 n)
           (negative-series (ln2 (+ n 1)))))

#|

 (stream-head 'ln2 (ln2 1) 10)
 (all-kind-accelerate-result (ln2 1) 10)
|#

(src 1. -.5 .3333333333333333 -.25 .2 -.16666666666666666 .14285714285714285 -.125 .1111111111111111 -.1)
(euler-transform 3.5714285714285754e-2 -.0098039215686275 4.032258064516098e-3 -2.0408163265305534e-3 1.1737089201877826e-3 -7.363770250368162e-4 4.921259842519676e-4 -3.4506556245686437e-4 2.512562814070418e-4 -1.8860807242548905e-4)
(accelerated-sequence 1. 3.5714285714285754e-2 8.068879311952798e-4 1.1143777059114406e-5 1.0412414891455865e-7 6.780819845601064e-10 2.3461045685571884e-12 -3.7828082000095906e-14 1.2449987764879285e-15 -3.570337399341144e-17)