Wednesday, June 3, 2009

Ex-1.38

;series 2,1,1,4,1,1,6,1,1..
;i starts with 0 that is (T 0) = 2 and so on
(define (T i)
(if (= (remainder i 3) 0)
(+ (* 2 (quotient i 3)) 2)
1))

;series 1,2,1,1,4,1,1,6,1,1,..
;i starts with 1 that is (D 1) = 1, (D 2)=2 and so on
(define (D i)
(if (= i 1) 1
(T (- i 2))))

;computing e
(+ 2 (cont-frac (lambda (i) 1.0) D 100))
;Value: 2.7182818284590455

No comments:

Post a Comment