Exercise 1.39
(define (cont-frac n d k)
(define (helper i)
(if (= i k)
0
(/ (n i)
(+ (d i) (helper (+ i 1))))))
(helper 1))
(define (tan-cf x k)
(cont-frac
(lambda (i) (if (= i 1) x (- (square x))))
(lambda (i) (- (* i 2) 1))
k))
(define quarter-pi (atan 1))
(tan-cf quarter-pi 1) ~> 0.7853981633974483
(tan-cf quarter-pi 2) ~> 0.9886892399342050
(tan-cf quarter-pi 3) ~> 0.9997876809149684
(tan-cf quarter-pi 4) ~> 0.9999978684156948
(tan-cf quarter-pi 5) ~> 0.9999999865263550
(tan quarter-pi) ~> 1