Re: Interval Arithmetic project



>>>>> "Raymond" == Raymond Rogers <Rogers> writes:

    >> -----Original Message-----
    >> From: Raymond Toy [mailto:raymond.toy at ericsson.com] 
    >> Sent: Thursday, May 04, 2006 5:16 PM
    >> (defun foo (x)
    >> (declare (type (double-float 9.5d0 10.5d0) x))
    >> (/ (+ x 20) (+ x 10)))
    >> 
    >> With cmucl, if you (compile 'foo) and then (describe 'foo), you
    >> get:
    >> 
    >> Its result type is:
    >> (DOUBLE-FLOAT 1.4390243902439024d0 1.564102564102564d0)
    >> 
    >> That is, (x+20)/(x+10) is always between 1.439... and 1.564... if x is
    >> [9.5,10.5].  I think that's right.
    >> 
    >> 
    Raymond> Say x was really a class/type; with y,z instantations of x.
    Raymond> The your cmucl program computed 
    Raymond> Interval((y+20)/(z+10))
    Raymond> Whereas interval((y+20)/(y+10))=[1.487..., 1.512...]
    Raymond> [30.5/20.5, 29.5/19.5]

Oh, right.  Yeah, the compiler is not smart enough to know that the
two parts are not independent.   If you rewrite it as 1+10/(y+10),
then cmucl will derive the answer as having the type (rational 19/2
21/2), just as you have.

Ray