# Interval Arithmetic

## by Cassio • 2011/09/19 • Research

Continuing the series on interval methods, this post will give us more details about interval arithmetic, the most popular interval formalism. In interval arithmetic each quantity (think of it as a scalar variable, or a floating point number in your favorite programming language x is represented as an interval , where .

Most operations in interval arithmetic are simple and intuitive. Some examples are:

- ;
- ;
- ;
- ;
- ;
- .

Intervals don’t have to be finite. There’s an empty interval, represented by , and an one or both interval limites can be infinite: . Interval arithmetic implementations typically handle invalid domain inputs (such as being asked to compute the square root of ) by operating only on the valid range (this is a design choice, and perhaps it would be preferred to “fail early” with an error).

There are numerous open source implementations of interval arithmetic in various languages, including C++ (part of Boost), MATLAB, Python, and others. There is also an online interval calculator you can play with.

Let’s work through a simple expression using intervals and the above operations. Say and . Let’s compute , in steps:

- ;
- ;
- ;
- ;
- .

While interval arithmetic operations are simple (and therefore fast implementations can be written) and mostly intuitive, they suffer from some issues. First, if an interval appears multiple times in the same computation, IA doesn’t know it represents the same quantity. This leads to some results that, from a real arithmetic perspective, are non-sensical. For instance, consider above. , while clearly the correct answer is 0.

This leads to an error explosion problem when the same quantity is repeatedly used in a chain of operations such as evaluating and polynomial. The end result is likely to bee too conservative (i.e., too wide) to be practical. For instance, still considering above, the simple expression leads to , which is 12 times wider than the real result, (just iterate through a few values for x and you’ll get there).

Several extensions and improvements to interval arithmetic have been proposed to handle these issues. The one I use in my PhD work is affine arithmetic, and I’ll talk about it next in this series.

Pingback: Affine Arithmetic | Cassio Pennachin()