Exercises in section 1.1 include exercises 1.1 to 1.8
Exercise 1.1 -- 1.6 has been given in the first section of constructor abstraction.
The following is a question for exercise 1.7 and exercise 1.8.
Practice 1.7
First, observe the program problems in the textbook.
It can be found that SQRT given in books cannot calculate the correct answer for a particularly small number, such as 0.00009. For a particularly large number, because the decimal precision is not enough to indicate the difference between two large numbers, SQRT will fall into an endless loop and cannot produce results.
To avoid this error, we follow the practice instructions for good-enough? Modify: the program does not detect the difference between the square of the guess value guess and X, but the ratio between the new and old guesses. When the ratio changes very small, the program stops improve.
New good-enough? Definition:
(Define (good-enough? Old-guess New-guess X); old-guess * newguess/X-1 (<(ABS (-(/(* Old-guess New-guess) x) 1 ))
The result is as follows:
Practice 1.8
Simply modify the Newton method to obtain the square root.
Question solution for SiCp ---- exercise in section 1.1