The sine of an angle (specified in radians) can be computed by making use of the approximation
to reduce the size of the argument of
(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?
p
is applied 5 times1.
sine
's order of operations (evaluating sine
before p
) generate a recursive process whose space and time complexity depend on the number of divisions by 3 required to yield an angle less than 0.1:
Footnotes
-
cf.
1.15.scm
. ↩