For MATLAB there is a popular interval arithmetic toolbox [http://www.ti3.tu-harburg.de/rump/intlab/ INTLAB] by Siegfried Rump (member of IEEE P1788). It had been free (as in free beer) for academic use in the past, but no longer is. Its origin dates back to 1999, so it is well tested and comprises a lot of functionality, especially for vector / matrix operations. INTLAB is compatible with GNU Octave since Version 9 [http://www.ti3.tuhh.de/rump/intlab/Octave/octave.html]. I don't know if INTLAB is or will be compliant with IEEE 1788.

+

For MATLAB there is a popular interval arithmetic toolbox [http://www.ti3.tu-harburg.de/rump/intlab/ INTLAB] by Siegfried Rump. It had been free of charge for academic use in the past, but no longer is. Its origin dates back to 1999, so it is well tested and comprises a lot of functionality, especially for vector / matrix operations. INTLAB is compatible with GNU Octave since Version 9 [http://www.ti3.tuhh.de/rump/intlab/Octave/octave.html]. I don't know if INTLAB is or will be compliant with IEEE 1788.

−

For C++ there is an interval library [https://github.com/nehmeier/libieeep1788/ libIEEE1788] by Marco Nehmeier (member of IEEE P1788). It aims to be standard compliant with IEEE 1788.

+

For C++ there is an interval library [https://github.com/nehmeier/libieeep1788/ libIEEE1788] by Marco Nehmeier (member of IEEE P1788). It aims to be standard compliant with IEEE 1788 and is designed in a modular way, supporting several interval data types and different flavors of interval arithmetic. [http://www.youtube.com/watch?v=GOa9aWAZO_Q]

For Java there is a library [https://java.net/projects/jinterval/ jinterval] by Dmitry Nadezhin (member of IEEE P1788). It aims to be standard compliant with IEEE 1788, but is not complete yet.

For Java there is a library [https://java.net/projects/jinterval/ jinterval] by Dmitry Nadezhin (member of IEEE P1788). It aims to be standard compliant with IEEE 1788, but is not complete yet.

Motivation

Give a digital computer a problem in arithmetic, and it will grind away methodically, tirelessly, at gigahertz speed, until ultimately it produces the wrong answer. … An interval computation yields a pair of numbers, an upper and a lower bound, which are guaranteed to enclose the exact answer. Maybe you still don’t know the truth, but at least you know how much you don’t know.

Floating-point arithmetic, as specified by IEEE 754, is available in almost every computer system today. It is wide-spread, implemented in common hardware and integral part in programming languages. For example, the double-precision format is the default numeric data type in GNU Octave. Benefits are obvious: The results of arithmetic operations are well-defined and comparable between different systems and computation is highly efficient.

However, there are some downsides of floating-point arithmetic in practice, which will eventually produce errors in computations.

Floating-point arithmetic is often used mindlessly by developers. [1][2]

The binary data types categorically are not suitable for doing financial computations. Very often representational errors are introduced when using “real world” decimal numbers. [3]

Even if the developer would be proficient, most developing environments / technologies limit floating-point arithmetic capabilities to a very limited subset of IEEE 754: Only one or two data types, no rounding modes, missing functions … [4]

Results are hardly predictable. [5] All operations produce the best possible accuracy at runtime, this is how a floating point works. Contrariwise, financial computer systems typically use a fixed-point arithmetic (COBOL, PL/I, …), where overflow and rounding can be precisely predicted at compile-time.

Results are system dependent. All but the most basic floating-point operations are not guaranteed to be accurate and produce different results depending on low level libraries and hardware. [6][7]

If you do not know the technical details (cf. first bullet) you ignore the fact that the computer lies to you in many situations. For example, when looking at numerical output and the computer says “ans = 0.1,” this is not absolutely correct. In fact, the value is only close enough to the value 0.1. Additionally, many functions produce limit values (∞ × −∞ = −∞, ∞ ÷ 0 = ∞, ∞ ÷ −0 = −∞, log (0) = −∞), which is sometimes (but not always!) useful when overflow and underflow occur.

Interval arithmetic addresses above problems in its very special way and introduces new possibilities for algorithms. For example, the interval newton method is able to find all zeros of a particular function.

Theory

Moore's fundamental theroem of interval arithmetic

Let y = f(x) be the result of
interval-evaluation of f over a box x = (x1, … , xn)
using any interval versions of its component library functions. Then

In all cases, y contains the range of f over x, that is, the set of f(x) at points of x where it is defined: y ⊇ Rge(f | x) = {f(x) | x ∈ x ∩ Dom(f) }

If also each library operation in f is everywhere defined on its inputs, while evaluating y, then f is everywhere defined on x, that is Dom(f) ⊇ x.

If in addition, each library operation in f is everywhere continuous on its inputs, while evaluating y, then f is everywhere continuous on x.

If some library operation in f is nowhere defined on its inputs, while evaluating y, then f is nowhere defined on x, that is Dom(f) ∩ x = Ø.

Online Introductions

Interval analysis in MATLAB Note: The INTLAB toolbox for Matlab is not compatible with the interval package for GNU Octave. For example, INTLAB additionally supports intervals in mid-rad form with complex values, INTLAB has no representation of an empty interval and INTLAB provides several other features that this interval package is missing. However, basic operations can be compared and should be compatible for common intervals.

What to expect

The interval arithmetic provided by this interval package is slow, but accurate.

Why is the interval package slow?
All arithmetic interval operations are simulated in high-level octave language using C99 or multi-precision floating-point routines, which is a lot slower than a hardware implementation [8]. Building interval arithmetic operations from floating-point routines is easy for simple monotonic functions, e. g., addition and subtraction, but is complex for others, e. g., interval power function, atan2, or reverse functions. For some interval operations it is not even possible to rely on floating-point routines, since not all required routines are available in C99 or BLAS.

Great algorithms and optimizations exist for floating-point matrix arithmetic in GNU Octave. Good interval versions of these still have to be found and implemented. For example, multiplication of matrices with many elements becomes unfeasible as it takes a lot of time. (For that purpose one could use the INTLAB toolbox, which uses a less accurate arithmetic)

Why is the interval package accurate?
The GNU Octave built-in floating-point routines are not useful for interval arithmetic: Their results depend on hardware, system libraries and compilation options.
The interval package handles all arithmetic functions with the help of the GNU MPFR library. With MPFR it is possible to compute system-independent, valid and tight enclosures of the correct results.

Quick start introduction

Input and output

Before exercising interval arithmetic, interval objects must be created from non-interval data. There are interval constants empty and entire and the class constructors infsup for bare intervals and infsupdec for decorated intervals. The class constructors are very sophisticated and can be used with several kinds of parameters: Interval boundaries can be given by numeric values or string values with decimal numbers. Also it is possible to use so called interval literals with square brackets.

It is possible to access the exact numeric interval boundaries with the functions inf and sup. The shown text representation of intervals can be created with intervaltotext. The default text representation is not guaranteed to be exact (see function intervaltoexact for that purpose), because this would massively spam console output. For example, the exact text representation of realmin would be over 700 decimal places long! However, the default text representation is correct as it guarantees to contain the actual boundaries and is accurate enough to separate different boundaries.

Warning: Decimal fractions as well as numbers of high magnitude (> 253) should always be passed as a string to the constructor. Otherwise it is possible, that GNU Octave introduces conversion errors when the numeric literal is converted into floating-point format before it is passed to the constructor.

Specialized interval constructors

Above mentioned interval construction with decimal numbers or numeric data is straightforward. Beyond that, there are more ways to define intervals or interval boundaries.

Hexadecimal-floating-constant form: Each interval boundary may be defined by a hexadecimal number (optionally containing a point) and an exponent field with an integral power of two as defined by the C99 standard (ISO/IEC9899, N1256, §6.4.4.2). This can be used as a convenient way to define interval boundaries in double-precision, because the hexadecimal form is much shorter than the decimal representation of many numbers.

Rational literals: Each interval boundary may be defined as a fraction of two decimal numbers. This is especially useful if interval boundaries shall be tightest enclosures of fractions, that would be hard to write down as a decimal number.

Uncertain form: The interval as a whole can be defined by a midpoint or upper/lower boundary and an integral number of “units in last place” (ULPs) as an uncertainty. The format is m?ruE, where

m is a mantissa in decimal,

r is either empty (which means ½ ULP) or is a non-negative decimal integral ULP count or is the ? character (for unbounded intervals),

u is either empty (symmetrical uncertainty of r ULPs in both directions) or is either u (up) or d (down),

E is either empty or an exponent field comprising the character e followed by a decimal integer exponent (base 10).

Interval vectors and matrices

Vectors and matrices of intervals can be created by passing numerical matrices, char vectors or cell arrays to the infsup constructor. With cell arrays it is also possible to mix several types of boundaries.

Decorations

With the subclass infsupdec it is possible to extend interval arithmetic with a decoration system. Every interval and intermediate result will additionally carry a decoration, which may provide additional information about the final result. The following decorations are available:

Decoration

Bounded

Continuous

Defined

Definition

com(common)

✓

✓

✓

x is a bounded, nonempty subset of Dom(f); f is continuous at each point of x; and the computed interval f(x) is bounded

dac(defined & continuous)

✓

✓

x is a nonempty subset of Dom(f); and the restriction of f to x is continuous

def(defined)

✓

x is a nonempty subset of Dom(f)

trv(trivial)

always true (so gives no information)

ill(ill-formed)

Not an interval, at least one interval constructor failed during the course of computation

In the following example, all decoration information is lost when the interval is possibly divided by zero, i. e., the overall function is not guaranteed to be defined for all possible inputs.

Arithmetic functions in a set-based interval arithmetic follow these rules: Intervals are sets. They are subsets of the set of real numbers. The interval version of an elementary function such as sin(x) is essentially the natural extension to sets of the corresponding point-wise function on real numbers. That is, the function is evaluated for each number in the interval where the function is defined and the result must be an enclosure of all possible values that may occur.

Reverse arithmetic operations

Reverse power operations. A relevant subset of the function's domain is outlined and hatched. In this example we use xy ∈ [2, 3].

Some arithmetic functions also provide reverse mode operations. That is inverse functions with interval constraints. For example the sqrrev can compute the inverse of the sqr function on intervals. The syntax is sqrrev (C, X) and will compute the enclosure of all numbers x ∈ X that fulfill the constraint x² ∈ C.

In the following example, we compute the constraints for base and exponent of the power function pow as shown in the figure.

Matrix operations

Above mentioned operations can also be applied element-wise to interval vectors and matrices. Many operations use vectorization techniques.

In addition, there are matrix operations on interval matrices. These operations comprise: dot product, matrix multiplication, vector sums (all quite accurate), matrix inversion, matrix powers, and solving linear systems (the latter are less accurate). As a result of missing hardware / low-level library support and missing optimizations, these operations are quite slow compared to familiar operations in floating-point arithmetic.

Notes on linear systems

A system of linear equations in the form Ax = b with intervals can be seen as a range of classical linear systems, which can be solved simultaneously. Whereas classical algorithms compute an approximation for a single solution of a single linear system, interval algorithms compute an enclosure for all possible solutions of (possibly several) linear systems. Some characteristics should definitely be known when linear interval systems are solved:

If the linear system is underdetermined and has infinitely many solutions, the interval solution will be unbound in at least one of its coordinates. Contrariwise, from an unbound result it can not be concluded whether the linear system is underdetermined or has solutions.

If the interval result is empty in at least one of its coordinates, the linear system is guaranteed to be underdetermined and has no solutions. Contrariwise, from a non-empty result it can not be concluded whether all or some of the systems have solutions or not.

Wide intervals within the matrix A can easily lead to a superposition of cases, where the rank of A is no longer unique. If the linear interval system contains cases of linear independent equations as well as linear dependent equations, the resulting enclosure of solutions will inevitably be very broad.

However, solving linear systems with interval arithmetic can produce useful results in many cases and automatically carries a guaranty for error boundaries. Additionally, it can give better information than the floating-point variants for some cases.

Error handling

Due to the nature of set-based interval arithmetic, you should never observe errors (in the sense of raised GNU Octave error messages) during computation. If you do, there either is a bug in the code or there are unsupported data types.

However, the interval constructors can produce errors depending on the input. The infsup constructor will fail if the interval boundaries are invalid. Contrariwise, the infsupdec constructor will only issue a warning and return a [NaI], which will propagate and survive through computations.

Related work

For MATLAB there is a popular interval arithmetic toolbox INTLAB by Siegfried Rump. It had been free of charge for academic use in the past, but no longer is. Its origin dates back to 1999, so it is well tested and comprises a lot of functionality, especially for vector / matrix operations. INTLAB is compatible with GNU Octave since Version 9 [22]. I don't know if INTLAB is or will be compliant with IEEE 1788.

For C++ there is an interval library libIEEE1788 by Marco Nehmeier (member of IEEE P1788). It aims to be standard compliant with IEEE 1788 and is designed in a modular way, supporting several interval data types and different flavors of interval arithmetic. [23]

For Java there is a library jinterval by Dmitry Nadezhin (member of IEEE P1788). It aims to be standard compliant with IEEE 1788, but is not complete yet.