From 736da82a653cb517ce38c4e7d0d2e93c19a9f7b5 Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <vu3rdd@gmail.com>
Date: Mon, 14 Jun 2010 15:08:27 +0530
Subject: [PATCH] solution to 2.15

---
 src/sicp/ch2_1_extended.clj |  2 +-
 src/sicp/ex2_15.clj         | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)
 create mode 100644 src/sicp/ex2_15.clj

diff --git a/src/sicp/ch2_1_extended.clj b/src/sicp/ch2_1_extended.clj
index dca737b..0631e7d 100644
--- a/src/sicp/ch2_1_extended.clj
+++ b/src/sicp/ch2_1_extended.clj
@@ -42,4 +42,4 @@
   (let [one (make-interval 1 1)]
     (div-interval one
 		  (add-interval (div-interval one r1)
-				(div-interval one r2)))))
\ No newline at end of file
+				(div-interval one r2)))))
diff --git a/src/sicp/ex2_15.clj b/src/sicp/ex2_15.clj
new file mode 100644
index 0000000..7072794
--- /dev/null
+++ b/src/sicp/ex2_15.clj
@@ -0,0 +1,32 @@
+(ns sicp.ex2_15
+  (:use [sicp utils ch2_1_extended ex2_7 ex2_8 ex2_12]
+	[clojure.test]))
+
+(def r1 (make-center-percent 1000 0.01))
+(def r2 (make-center-percent 100  0.01))
+
+(def r3 (sub-interval (add-interval r1 r2) r2))
+;;=> (999.8799999999999 1000.1200000000001)
+
+(percentage r3)
+;;=> 0.012000000000011824
+
+(center r3)
+;;=> 1000.0
+
+(comment
+"This shows that even if you add and subtract an interval (r2) from
+another interval, we get back an interval which is not the same as
+the original one r1. Let us look at the range as (center, percentage)
+pair.
+ r1 = c1 +/- w1
+ r2 = c2 +/- w2
+
+Now r1+r2-r2 = c1 + c2 - c1 +/- (2*w1+w2)
+             = c1 +/- (2*w1 + w2)
+
+i.e. we have a new percentage width as the errors add up. The inference
+from this is that, we reduce the number of ranges in a calculation to
+get a more accurate range. So, yes, Eva Lu Ator is right.
+"
+  )
\ No newline at end of file
-- 
2.45.2