Add Exercise 2.12

This commit is contained in:
Tobias Eidelpes 2022-11-05 14:58:25 +01:00
parent a14449600f
commit a79350dd76

View File

@ -105,3 +105,16 @@ and upper bound."
a
(make-interval (/ 1.0 (upper-bound b))
(/ 1.0 (lower-bound b))))))
;; Exercise 2.12
(defun make-center-width (c w)
(make-interval (- c w) (+ c w)))
(defun center (i)
(/ (+ (lower-bound i) (upper-bound i) 2.0)))
(defun width (i)
(/ (- (upper-bound i) (lower-bound i) 2.0)))
(defun make-center-percent (c p)
(make-interval (* c (- 1 (/ p 100)))
(* c (+ 1 (/ p 100)))))