【问题标题】:Creating and solving a recurrence relation for sine approximation创建和求解正弦逼近的递推关系
【发布时间】: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


    【解决方案1】:

    您将计算与计算所花费的时间混淆了。

    如果 θ≤0.1,则 T(θ) 为 1。否则,为 T(θ/3)+k,其中k 是执行四次乘法、一次减法和一些杂项记账所需的时间.

    很明显,第 ith 次递归的参数将是 θ/3i,因此递归将持续到 θ/3i ≤0.1。由于不等式成立的 i 的最小值是⌈log3(θ/0.1)⌉,我们可以看到 T(θ) = k*⌈log3(θ/0.1)⌉,即 O(logθ)。 (我省略了将最后一次递归与其他递归区分开来的小常数因子,因为它没有区别。)

    【讨论】:

    • 感谢您的回复。在谈论这类事情时,“应该很明显”是危险的语言。您介意详细说明一下,以便我可以对您进行绿色检查吗?
    • @Steve:已编辑。这不是很明显吗? :) 因为这是一个编程网站而不是math.stackexchange.com,所以我还是把正式证明留作练习。
    猜你喜欢
    • 1970-01-01
    • 2018-09-10
    • 1970-01-01
    • 1970-01-01
    • 2015-06-15
    • 2012-12-03
    • 2017-11-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多