Section 1.3.4 - Procedures as Returned Values
cubic will create and return procedures that should be solved using Newton’s
double is quite simple:
All the fun comes when trying to calculate something like
((double (double double)) inc).
(double double) essentially returns a procedure that applies the original
prodecure 4 times. Therefore
(double (double double)) will apply what it
receives receives \(4 * 4 = 16\) times. So if we start from \(5\):
Using the definition of
dx from above:
So the general function would be something like:
damps controls the number of repeated average damps.
Experimenting a bit showed that with 2 average damps we can calculate up to the
7th root. 3 average damps lets us calculate up to the 31st root. Using 4 damps
we were able to calculate at least up to the 512th root with no problems.
We first define
iterative-improve. Note that it returns an anonymous procedure
that itself creates and executes a recursive procedure:
Now we can implement
This concludes Chapter 1. Onwards to Chapter 2 then!