Exercise 1.35

Show that the golden ratio (the section Tree Recursion) is a fixed point of the transformation , and use this fact to compute by means of the fixed-point/2 function.

Exercise 1.36

Modify fixed-point/2 so that it prints the sequence of approximations it generates, using io:format as shown in exercise 1.22. Then find a solution to by finding a fixed point of . (Use Erlang's math:log function, which computes natural logarithms.) Compare the number of steps this takes with and without average damping. (Note that you cannot start fixed-point/2 with a guess of 1, as this would cause division by .)

Exercise 1.37

a. An infinite continued fraction is an expression of the form

As an example, one can show that the infinite continued fraction expansion with the and the all equal to 1 produces , where is the golden ratio (described in the section Tree Recursion]). One way to approximate an infinite continued fraction is to truncate the expansion after a given number of terms. Such a truncation -- a so-called k-term finite continued fraction -- has the form

Suppose that n and d are functions of one argument (the term index ) that return the and of the terms of the continued fraction. Define a function cont-frac/3 such that evaluating (cont-frac n d k) computes the value of the -term finite continued fraction. Check your function by approximating using

(cont-frac (lambda (i) 1.0)
           (lambda (i) 1.0)

for successive values of k. How large must you make k in order to get an approximation that is accurate to 4 decimal places?

b. If your cont-frac/3 function generates a recursive process, write one that generates an iterative process. If it generates an iterative process, write one that generates a recursive process.

Exercise 1.38

In 1737, the Swiss mathematician Leonhard Euler published a memoir De Fractionibus Continuis, which included a continued fraction expansion for , where is the base of the natural logarithms. In this fraction, the are all 1, and the are successively . Write a program that uses your cont-frac/3 function from exercise 1.37 to approximate , based on Euler's expansion.

Exercise 1.39

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

where is in radians. Define a function (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.