# Interval Arithmetic Using the Fortran Tools

Interval arithmetic capability is available with the Fortran Tools, thanks to a module provided by R. Baker Kearfott. This module is “built in” when using the Fortran Tools. It contains the definition of the derived type interval and the procedures to manipulate values of this type.

Quoting from an article by Kearfott:

“Interval arithmetic is useful in automatically verified computations, that is, in computations in which the algorithm itself rigorously proves that the answer must lie within certain bounds. In addition to rigor, interval arithmetic also provides a simple and sometimes sharp method of bounding ranges of functions for global optimization and other tasks.”

Using interval arithmetic, each ʺvalueʺ is really an interval of values. For example, if it is known that the value of a is between 1.3 and 1.5, it is represented as the interval [1.3, 1.5] between 1.3 and 1.5. If b is the interval [2.6. 2.9] then the sum a + b is in the interval [3.9, 4.4] and this is the sum of a and b in interval arithmetic. This is illustrated by the following simple program that uses interval arithmetic.

program add_intervals use interval_arithmetic implicit none type(interval) :: a, b, s character(len=*), parameter :: & interval_fmt = & "(' [', f0.2, ', ', f0.2, ']')" a = interval(1.3, 1.5) b = interval(2.6, 2.9) s = a + b write (unit=*, fmt=interval_fmt) s end program add_intervals

Running this program produces the output:

[3.90, 4.40]

The features of the interval arithmetic module are described in more detail in the file Interval_Arithmetic.txt in the doc directory of the Fortran Tools distribution.