0

From this example code I found online, which functions are the unaccelerated stream, the singly-accelrated stream, and the super-accelerated stream? Thank you in advance.

Cite: lawfulsamurai.blogspot.com/2009/01/sicp-section-35-streams.html

(define (log2-summands n)  
  (cons-stream (/ 1.0 n)  
           (stream-map - (log2-summands (+ n 1))))) 

(define log2-stream   
 (partial-sums (log2-summands 1))) 

(define log2-stream-euler   
  (euler-transform log2-stream))  

(define log2-stream-accelerated  
  (accelerated-sequence euler-transform log2-stream))  
King11
  • 1,239
  • 3
  • 9
  • 17
  • I think your code came from either http://wqzhang.wordpress.com/2009/08/12/sicp-exercise-3-65/ or http://lawfulsamurai.blogspot.com/2009/01/sicp-section-35-streams.html. Note that it's important to attribute the source of any code you post. – C. K. Young Nov 14 '14 at 04:16
  • Sorry about that. Next time I will cite examples – King11 Nov 14 '14 at 04:19
  • 1
    @King1 There's an "Edit" button under your question. You should cite examples not just next time, but this time too, *in the question* (since comments can be deleted without record at any time. Otherwise your question is likely to be deleted as plagiarism. – Joshua Taylor Nov 14 '14 at 12:49
  • @Joshua Taylor/Chris Jester-Young, Do either of you know the answer now that I've cited the code? – King11 Nov 15 '14 at 02:31
  • 1
    This question appears to be off-topic because it seems to be answered directly in the blog post that OP cited. – Joshua Taylor Nov 15 '14 at 13:23

1 Answers1

3

Well, you didn't tell us what either a "singly-accelrated" or "super-accelerated" are, so it's hard to say where in the code they are. It's like playing "Where's Waldo", but without knowing what a "Waldo" is.

That said, I can see that log2-summands, euler-transform, make-tableau, and accelerated-sequence all return streams, so it seems like they'd be the candidates. Now, if we actually look at the blog post that you linked to, SICP Section 3.5 Streams, we read:

  1. Straightforward summation using partial-sums. The value of log2 oscillates between 0.6687714031754279 and 0.7163904507944756 after 20 iterations.

    (define log2-stream   
      (partial-sums (log2-summands 1)))  
    
  2. Log2 using Euler Transformation. Value converges to 0.6932106782106783 after 10 iterations.

    (define log2-stream-euler   
      (euler-transform log2-stream))  
    
  3. Accelerated summation. Value converges to 0.6931488693329254 in 4 iterations.

    (define log2-stream-accelerated  
      (accelerated-sequence euler-transform log2-stream))
    

It sounds like that the log2-stream, log2-stream-euler, and log2-stream-accelerated are, respectively, the "unaccelerated stream, the singly-accelrated stream, and the super-accelerated stream".

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353