# [Maxima] Re: Interval Arithmetic project

Richard Fateman fateman at cs.berkeley.edu
Wed May 3 15:13:08 CDT 2006

```Raymond Toy wrote:

>
>
>Yeah, I was lazy.  Plus, I wasn't sure how to do directed rounding
>when you mix a single-float with a double-float.
>
>
>

Off the top of my head...

Given any floating point number, I claim it is of infinite precision.
Just extend the bits in the
fraction by binary 000000,  and can be exactly written as a rational
number e.g.  fraction/2^n or
fraction * 2^n.

Given two numbers   r and s,   where they can be single, double,
integer, rational.

Convert them to exact rational.     Add them to get a rational number
r+s= Q,

If you need to make an interval of double-floats where Q  is a lower
[resp, upper] end point,
convert Q to a double-float.   If it is exactly representable as a
double-float, you are
done.  Otherwise find the closest double-float which is less than
[resp., greater than] Q, and
use that as the endpoint.

It is not actually necessary to do the arithmetic in rational numbers,
but however you
do it should get the same answer.

There are additional concerns about overflow,  or if  r or s or both are
NaNs or Infs.
I have found it rather appealing to convert NaN to the rational 0/0  and
Inf to 1/0 or -1/0.
If you go through the motions of rational arithmetic, you come up with a
very nearly consistent arithmetic.

Also, it is hard to tell if you have x-x   or x-y when someone types in

interval(-1,1)-interval(-1,1),   and simplifying that to 0 is probably
wrong.

I am thinking about another model in which the symbolic and numeric phases
are separated.

RJF

```