From 16bc240d870f856872edb2fa1b595150a4e50619 Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <vu3rdd@gmail.com>
Date: Mon, 14 Jun 2010 01:37:31 +0530
Subject: [PATCH] solution to 2.11.

---
 src/sicp/ex2_11.clj | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/sicp/ex2_11.clj b/src/sicp/ex2_11.clj
index 03fbfd0..2909020 100644
--- a/src/sicp/ex2_11.clj
+++ b/src/sicp/ex2_11.clj
@@ -44,5 +44,26 @@
 ;; -   -   -   +
 ;; -   -   -   -
 
-
-;; too boring a problem. Skipping the rest of it.
+(defn new-mul-interval [x y]
+  (let [l1 (lower-bound x)
+	u1 (upper-bound x)
+	l2 (lower-bound y)
+	u2 (upper-bound y)
+	sl1? (pos? l1)
+	su1? (pos? u1)
+	sl2? (pos? l2)
+	su2? (pos? u2)]
+    (cond (and sl1? su1? sl2? su2?)             (make-interval (* l1 l2) (* u1 u2))
+	  (and sl1? su1? (not sl2?) su2?)       (make-interval (* u1 l2) (* u1 u2))
+	  (and sl1? su1? (not sl2?) (not su2?)) (make-interval (* u1 l2) (* u2 l1))
+	  (and (not sl1?) su1? sl2? su2?)       (make-interval (* l1 u2) (* u1 u2))
+	  (and (not sl1?) su1? (not sl2?) (not su2?)) (make-interval (* u1 l2) (* l1 l2))
+	  (and (not sl1?) (not su1?) sl2? su2?) (make-interval (* l1 u2) (* u1 l2))
+	  (and (not sl1?) (not su1?) (not sl2?) su2?) (make-interval (* l1 u2) (* l1 l2))
+	  (and (not sl1?) (not su1?) (not sl2?) (not su2?)) (make-interval (* u1 u2) (* l1 l2))
+	  (and (not sl1?) su1? (not sl2?) su2?) (let [p1 (* l1 l2)
+						      p2 (* l1 u2)
+						      p3 (* u1 l2)
+						      p4 (* u1 u2)]
+						  (make-interval (min p1 p2 p3 p4)
+								 (max p1 p2 p3 p4))))))
\ No newline at end of file
-- 
2.45.2