Interval Arithmetic

Interval[{min,max}]the interval from min to max
Interval[{min1,max1},{min2,max2},]
the union of intervals from to , to ,

Representations of real intervals.

This represents all numbers between and .
In[1]:=
Click for copyable input
Out[1]=
The square of any number between and is always between and .
In[2]:=
Click for copyable input
Out[2]=
Taking the reciprocal gives two distinct intervals.
In[3]:=
Click for copyable input
Out[3]=
Abs folds the intervals back together again.
In[4]:=
Click for copyable input
Out[4]=
You can use intervals in many kinds of functions.
In[5]:=
Click for copyable input
Out[5]=
Some functions automatically generate intervals.
In[6]:=
Click for copyable input
Out[6]=
IntervalUnion[interval1,interval2,]find the union of several intervals
IntervalIntersection[interval1,interval2,]
find the intersection of several intervals
IntervalMemberQ[interval,x]test whether the point x lies within an interval
IntervalMemberQ[interval1,interval2]test whether lies completely within

Operations on intervals.

This finds the overlap of the two intervals.
In[7]:=
Click for copyable input
Out[7]=
You can use Max and Min to find the end points of intervals.
In[8]:=
Click for copyable input
Out[8]=
This finds out which of a list of intervals contains the point 7.
In[9]:=
Click for copyable input
Out[9]=

You can use intervals not only with exact quantities but also with approximate numbers. Even with machineprecision numbers, the Wolfram Language always tries to do rounding in such a way as to preserve the validity of results.

This shows explicitly the interval treated by the Wolfram Language as the machineprecision number
In[10]:=
Click for copyable input
Out[10]=
This shows the corresponding interval around , shifted back to zero.
In[11]:=
Click for copyable input
Out[11]=
The same kind of thing works with numbers of any precision.
In[12]:=
Click for copyable input
Out[12]=
With ordinary machineprecision arithmetic, this computation gives an incorrect result.
In[13]:=
Click for copyable input
Out[13]=
The interval generated here, however, includes the correct value of 0.
In[14]:=
Click for copyable input
Out[14]=