]> git.rkrishnan.org Git - sicp.git/blob - src/sicp/ex2_9.clj
Merge branch 'master' of github.com:vu3rdd/sicp
[sicp.git] / src / sicp / ex2_9.clj
1 (ns sicp.ex2_9
2   (:use [sicp utils ch2_1_extended ex2_7]
3         [clojure.test]))
4
5 ;; let us say, width of an interval [x,y] = d = (y-x)/2.
6 ;; add_interval [x,y] = [l1+l2, u1+u2]
7 ;; width of sum = (u1+u2 - (l1+l2))/2
8 ;;              = (u1-l1 + u2 - l2)/2
9 ;;              = d1  + d2
10 ;;
11 ;; sub_interval [x,y] = [l1-u2, u1-l2]
12 ;; width of diff = (u1-l2 - (l1-u2))/2
13 ;;               = (u1 - l2 - l1 + u2) / 2
14 ;;               = ((u1 - l1) + (u2 - l2))/2
15 ;;               = d1 + d2
16
17 ;; Now, intuitively multiplication (and division), scales a range
18 ;; up or down. Since mul-range was essentially non-linear (is that the
19 ;; right term? ) because of the min/max calculations, these depend on
20 ;; absolute values of the range rather than the width.
21 ;; eg: [2 3] [3 4]. Width (d1, d2) => (1,1)
22 ;; mul-interval => [6 12]
23
24 ;; same with division as well.