Exercise 1.39.

A continued fraction representation of the tangent function was published in 1770 by the German mathematician J.H. Lambert:

              x
tan x = —————————————
                x²
        1 − —————————
                 x²
          3 − ———————

             5 −  ⋱

where x is in radians. Define a procedure (tan-cf x k) that computes an approximation to the tangent function based on Lambert's formula. K specifies the number of terms to compute, as in exercise 1.37.

Solutions

Here's mine.

-inimino

(define (tan-cf x k)
  (cont-frac (lambda (i) (if (= i 1) x (* -1 x x)))
             (lambda (i) (- (* 2 i) 1))
             k))
 
exercise_1.39.txt · Last modified: 2009/02/27 00:13 by inimino
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki