The signs of the endpoints of the intervals

In passing, Ben also cryptically comments: «By testing the signs of the endpoints of the intervals, it is possible to break mul-interval into nine cases, only one of which requires more than two multiplications». Rewrite this procedure using Ben's suggestion.


There are no comments yet.

Authentication required

You must log in to post a comment.

Login
(define (make-interval a b)
  (cons a b))

(define (lower-bound interval)
  (car interval))

(define (upper-bound interval)
  (cdr interval))


(define interval (make-interval -5 15))
(define interval2 (make-interval 5 10))
(define interval3 (make-interval 6 8))

(define result1 (mul-interval interval interval2))
(define result2 (mul-interval interval2 interval))
(define result3 (mul-interval interval2 interval3))

(check-equal? result1 result2)
(check-equal? result3 '(30 . 80))