2.14|

$ cd ~

SICP Exercise 2.14

Added 3 intervals to test:

(define (par1 r1 r2)
  (div-interval (mul-interval r1 r2)
                (add-interval r1 r2)))

(define (par2 r1 r2)
  (let ((one (make-interval 1 1)))
    (div-interval one
                  (add-interval (div-interval one r1)
                                (div-interval one r2)))))

(define ina (make-center-percent 20 5))
(define inb (make-center-percent 30 1))
(define inc (make-center-percent 10 0))

Now running:

> (display (par1 ina inb))
(11.0 . 13.06570841889117)
> (display (par2 ina inb))
(11.587268993839837 . 12.403508771929825)
> (center (div-interval ina ina))
1.0050125313283207
> (percent (div-interval ina ina))
9.975062344139651

Clearly the two procedures return different results. Ideally the center and percent should return 1.0 and 0 respectively.