some solutions for MIT Press's "structure and interpretation of computer programs", I guess
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
554 B

(define (cube x) (* x x x))
(define (p x) (- (* 3 x) (* 4 (cube x))))
(define (sine ang)
(if (not (> (abs ang) 0.1))
ang
(p (sine (/ ang 3.0)))))
(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.975846533167877))
;; -> (p -0.789563114470821)
;; => -0.399803457413348
;; a: 5
;; b: space: O(log(x))
;; steps: O(log(x))