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
x
=
3
sin
x
3
−
4
sin
3
x
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)))))
How many times is the procedure p applied when (sine 12.15) is
evaluated?
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?
练习 1.15:当 x 足够小时,可以用近似式 sin x ≈ x 来计算角度(以弧度表示)的正弦值,并利用三角恒等式
sin x = 3 sin(x/3) − 4 sin³(x/3)
来缩小 sin 的参数。(在本题中,若角度的绝对值不大于 0.1 弧度,则认为该角度"足够小"。)下面的过程体现了上述思想:
(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)))))
在对 (sine 12.15) 求值时,过程 p 被调用了几次?
在对 (sine a) 求值时,由 sine 过程产生的计算过程在空间和步骤数方面(关于 a 的函数)的增长阶分别是多少?
(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)))))