【发布时间】:2015-11-15 03:41:24
【问题描述】:
在 SICP 中,有一个问题(练习 1.15)说
Exercise 1.15. The sine of an angle (specified in radians) can be
computed by making use of the approximation sin x x if x is
sufficiently small, and the trigonometric identity
sin(r) = 3sin(r/3) - 4sin^3(r/3)
to reduce the size of the argument of sin. (For purposes of this
exercise an angle is considered ``sufficiently small'' if its
magnitude is not greater than 0.1 radians.) These ideas are incorporated
in the following procedures:
(define (cube x) (* x x x))
(define (p x) (- (* 3 x) (* 4 (cube x))))
(define (sine angle)
(if (not (> (abs angle) 0.1))
angle
(p (sine (/ angle 3.0)))))
a. How many times is the procedure p applied when (sine 12.15) is evaluated?
b. What is the order of growth in space and number of steps
(as a function of a) used by the process generated by the
sine procedure when (sine a) is evaluated?
您可以通过运行它来分析它,并看到它变成了O(loga),其中a是弧度的输入角度。
但是,这还不够。这应该可以通过递归关系来证明。我可以这样设置循环关系:
T(a) = 3T(a/3) - 4T(a/3)^3
这是同质的:
3T(a/3) - 4T(a/3)^3 - T(a) = 0
但是,它是非线性的。我不确定如何获得这个特征方程,以便我可以解决它并向自己证明O(loga) 不仅仅是“直觉上的真实”。互联网上似乎没有任何教程涵盖这种分析,我唯一看到的结论是非线性递归几乎不可能解决。
谁能帮忙?
谢谢!
【问题讨论】:
标签: algorithm scheme time-complexity complexity-theory recurrence