SCIP 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
sinr=3sin(r/3)- 4(sin(r/3))^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))))
48
(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?

(defun cube(x)
  (* x x x))


(defun p(x)
  (- (* 3 x)
     (* 4 (cube x))))


(defun mysin(angle )
  (if (<= (abs angle)
	 0.1)
      angle
      (p (mysin (/ angle 3)  ))))



(sine 12.15)
(p (sine 4.05))
(p (p (sine 1.35)))
(p (p (p (sine 0.45))))
(p (p (p (p (sine 0.15)))))
(p (p (p (p (p (sine 0.05))))))
(p (p (p (p (p 0.05)))))
(p (p (p (p 0.1495))))
(p (p (p 0.4351345505)))
(p (p 0.9758465331678772))
(p -0.7895631144708228)
-0.39980345741334

quote:www.billthelizard.com/2009/12/sicp-exercise-115-calculating-sines.html


The order of growth in space and number of steps is (log310a) 

quote: http://jots-jottings.blogspot.jp/2011/09/sicp-115-sines-of-fathers.html
  
Edit in Emacs with Slime and Steel Bank Common Lisp.