Exercise 1.46: Several of the numerical methods
described in this chapter are instances of an extremely general computational
strategy known as
iterative improvement. Iterative improvement says
that, to compute something, we start with an initial guess for the answer, test
if the guess is good enough, and otherwise improve the guess and continue the
process using the improved guess as the new guess. Write a procedure
iterative-improve that takes two procedures as arguments: a method for
telling whether a guess is good enough and a method for improving a guess.
Iterative-improve should return as its value a procedure that takes a
guess as argument and keeps improving the guess until it is good enough.
Rewrite the sqrt procedure of 1.1.7 and the
fixed-point procedure of 1.3.3 in terms of
iterative-improve.
练习 1.46:本章描述的几种数值方法都是一种极为通用的计算策略——迭代改进 (iterative improvement) 的实例。迭代改进的思路是:要计算某个量,先从一个初始猜测值出发,检验该猜测是否足够好,否则改进猜测并以改进后的猜测作为新猜测继续这一过程。编写过程 iterative-improve,它以两个过程为参数:一个判断猜测是否足够好的方法,以及一个改进猜测的方法。iterative-improve 应返回一个过程,该过程以猜测为参数,并不断改进猜测直到足够好为止。用 iterative-improve 重写 1.1.7 节的 sqrt 过程和 1.3.3 节的 fixed-point 过程。