From a45d553a3a934a1840bf85c2f7f96f5c3c8a406e Mon Sep 17 00:00:00 2001 From: hongwen000 Date: Mon, 27 Mar 2017 19:46:42 +0800 Subject: [PATCH] Update 2.10.scm I have a different understanding of this question. I think it means that if interval y spans zero, eg [-1, 1], an error should be threw. --- chapter2/2.10.scm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/chapter2/2.10.scm b/chapter2/2.10.scm index 7c519ea..fc56272 100644 --- a/chapter2/2.10.scm +++ b/chapter2/2.10.scm @@ -17,9 +17,9 @@ (max p1 p2 p3 p4)))) (define (div-interval x y) - (if (= (upper-bound y) - (lower-bound y)) - (error "Division by zero") - (mul-interval x - (make-interval (/ 1.0 (upper-bound y)) - (/ 1.0 (lower-bound y)))))) + (if (> (* (lower-bound y) + (upper-bound y)) 0) + (mul-interval x + (make-interval (/ 1.0 (upper-bound y)) + (/ 1.0 (lower-bound y)))) + (error "Division by an interval spanning zero")))