灯下 登录
计算机科学 / SICP / 1.1.7 Example: Square Roots by Newton’s Method

Exercise 1.7 · 习题

Exercise 1.7: The good-enough? test used

in computing square roots will not be very effective for finding the square

roots of very small numbers. Also, in real computers, arithmetic operations

are almost always performed with limited precision. This makes our test

inadequate for very large numbers. Explain these statements, with examples

showing how the test fails for small and large numbers. An alternative

strategy for implementing good-enough? is to watch how guess

changes from one iteration to the next and to stop when the change is a very

small fraction of the guess. Design a square-root procedure that uses this

kind of end test. Does this work better for small and large numbers?

练习 1.7:在计算平方根时使用的 good-enough? 检验对于很小的数并不十分有效。此外,在实际计算机中,算术运算几乎总是以有限精度执行的。这使得我们的检验对于非常大的数也不够用。结合具体示例,解释这些说法,说明检验在小数和大数上如何失效。实现 good-enough? 的另一种策略是观察 guess 从一次迭代到下一次迭代的变化,当变化相对于 guess 来说非常小时停止计算。设计一个使用这种终止检验的平方根过程。这种方法对小数和大数的效果更好吗?