Disclaimer:
Permission to use, copy,
and distribute this software and
It’s documentation for any non commercial purpose is hereby granted without fee,
provided:
THE SOFTWARE IS PROVIDED "ASIS" AND WITHOUT WARRANTY OF ANY KIND,
EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO
EVENT SHALL Henrik Vestermark, BE LIABLE FOR ANY
SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY
OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. 

Interval Arithmetic. 

Here is a simple interval arithmetic template class that support the c++ build in base type of float and double. There is only one header file to be included to make it happen and that is the header file intervaldouble.h
Building an interval template class that can handle all interval arithmetic for IEEE754 floating point is just down to simple math. This paper you can also download describe the practical implementation aspect of building an interval template class and discuss the tricks and math that is behind the implementation. The implementation spans from the basic operators like _,,*,/ to elementary functions like sqrt(), log(), pow(), exp() to trigonometric functions of sin(), cos(), tan(), asin(), acos() and atan(). Of course it also support interval constants like π, ln2 and ln10. The interval arithmetic support the basic C++ types of float & double.
Click here to donwload the template class header file. intervaldouble.h
Click here to download the paper "Interval Arithmetic. A Pratical implementation. Download 

Intervaldouble.h is version 1.01 from April 2015

Examples of using the interval arithmetic template class:
// This example show how to evaluate a polynomial with complex coefficients a, at a
// complex point z and output the result as a complex interval that is the bound of the
// evaluation error. The evaluation is done using Horner algorithm
#include "intervaldouble.h"
#include <complex>
complex<interval<double> > horner(const register int n, const complex<double> a[], complex<double> z)
{
complex<interval<double> > fval;
complex<interval<double> > zi=z;
fval = a[0];
for (int i = 1; i <= n; i++) fval = fval * zi + complex<interval<double> > (a[i]);
return fval;
}
int test_horner()
{
complex<double> a[6], z;
complex<interval<double> > res;
a[0] = 1.0;
a[1] = 1.5;
a[2] = +2.5;
a[3] = 3.5;
a[4] = +4.5;
a[5] = 5.5;
z = 1.364018313559659;
res = horner(5, a, z);


