1 ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 ;; about the language level of this file in a form that our tools can easily process.
3 #reader(lib "htdp-advanced-reader.ss" "lang")((modname |31.3|) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #t #t none #f ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp")))))
4 ;sum-2 : (listof numbers) -> number
9 (sum-1 (rest alon)))]))
11 ;sum-2 : (listof numbers) -> number
13 ;sum-a : (listof numbers) number -> number
16 (local ;;accumulator represents the sum of all the numbers preceding alon in alon0
17 ((define (sum-a alon accumulator)
19 [(empty? alon) accumulator]
20 [else (sum-a (rest alon) (+ (first alon) accumulator))])))
26 [else (cons (expt -0.99 n) (g-series (sub1 n)))]))
28 (sum-1 (g-series #i100000))
29 (sum-2 (g-series #i100000))
31 (* 10e15 (sum-1 (g-series #i100000)))
32 (* 10e15 (sum-2 (g-series #i100000)))
34 ;right->left has errors (abs much larger than 0)
36 ;But strange, not what I predicted