]> git.rkrishnan.org Git - sicp.git/blob - src/sicp/ex2_8.clj
Merge branch 'master' of github.com:vu3rdd/sicp
[sicp.git] / src / sicp / ex2_8.clj
1 (ns sicp.ex2_8
2   (:use [sicp utils ch2_1_extended ex2_7]
3         [clojure.test]))
4
5 ;; sub-interval
6 (defn sub-interval [x y]
7   (make-interval (- (lower-bound x) (upper-bound y))
8                  (- (upper-bound x) (lower-bound y))))
9
10 ;; subtraction of an interval can be seen as addition of a
11 ;; negative range. Intuitively, if you plot a range in a 2-D graph,
12 ;; negative of a range, say [a1, a2] for say a1 and a2 positive
13 ;; is [-a2, -a1]. i.e. the reflection of the range w.r.t the x=0
14 ;; axis. In this new light, we are adding two ranges [-a2,-a2] and [b1,b2]
15 ;; and hence the above answer.