ISReal, a C++ library, for floating-point computation with controlled error. Given a floating-point expression `f`

and an expected upper bound of error `e`

, ISReal automatically and dynamically adjusts precisions of all intermediate computations to produce the result `y`

such that `|y-f|<e`

. ISReal could potentially be combined with existing approaches for floating-point programs analysis to provide more informed result [1,2].

ISReal relies on GNU MP for big integer computation. ISReal supports the following operations with degree and radian modes for (inverse) trigonometric functions:

- Special constants:
`e`

and`pi`

; - Elementary operations:
`+`

,`-`

,`*`

, and`/`

; - Trigonometry:
`sin`

,`cos`

,`tan`

,`cot`

,`sec`

and`csc`

; - Inverse trigonometry:
`arcsin`

,`arccos`

,`arctan`

and`arccot`

; - Logarithm and exponent:
`ln`

,`log`

and`^`

; - Hyperbolic functions:
`sinh`

and`cosh`

; - Rounding:
`floor`

and`ceil`

; - Factorial:
`!`

.

Let us consider the expression

where `a = 77617.01`

, `b=33096.0`

.

Its actual value: `-0.82739605994682136814116509579816....`

In ISReal form, it is:

`333.75*33096.0^6+77617.0^2*(11*77617.0^2*33096.0^2-33096.0^6-121*33096.0^4-2) +5.5*33096.0^8+77617.0(2*33096.0)`

The results of our tool ISReal under three precisions

`8`

,`16`

and`20`

were:- 8 Precision:
−0.82739606 - 16 Precision:
−0.8273960599468214 - 20 Precision:
−0.82739605994682136814

- 8 Precision:
On an IBM S/370 computer, the results obtained by Rump 4] using Fortran program were:

- single:
1.172603... - double:
1.1726039400531... - extended:
1.172603940053178...

- single:
On a Pentium4-based workstation, using GCC and the Linux system were [5]:

- single:
2.0317×1029 ; - double:
5.960604×1020 ; - double-extended:
−9.38724×10−323 .

- single:
The results in the Forte Developer 6 Update 2 Fortran 95 compiler (IEEE 754) from Sun Microsystems Inc. were [6]:

- single:
−6.338253×1029 ; - double:
−1.1805916207174113×1021 ; - quadruple:
1.1726039400531786318588349045201838 .

- single:
The results on Windows 8.1 with 8GB RAM and AMD64 CPU A10-6700 3.70GHz (Win8 for short) using Microsoft VS2012 were (using all modes: precise, precise, fast, long double is mapped to double in Microsoft VS 2012):

- single:
−9.8750123322992547×1029 ; - double:
−1.1805916207174113×1021 .

- single:
The results on Ubuntu 16.10 and Intel CORE i7 (Ubuntu for short) using GCC 6.2.0 were:

- single:
−9.8750123322992547249669537792×1029 ; - double:
−1.180591620717411303424×1021 ; - long double:
5.764607523034234891875×1017 .

- single:
Maple 15 under three significant digits:

`8`

,`16`

and`20`

, the results were:- 8 significant digits:
7×1029 ; - 16 significant digits:
1×1021 ; - 20 significant digits:
−9.9999999999999998827×1016 .

- 8 significant digits:
The results using Matlab R2012a were:

- Directly computing:
−1.1806×1021 ; - 8 significant digits(Math Toolbox):
−1.1805916×1021 ; - 16 significant digits(Math Toolbox):
−1.180591620717411×1021 ; - 20 significant digits(Math Toolbox):
−1.1805916207174113034×1021 .

- Directly computing:

All the following tools have been tested on Windows XP/7/8. To build source code, we recommand to use Microsoft Visual Studio 2010 or later versions.

- ISReal GUI-based calculator [source code] [exe]
- ISReal dynamic library [source code] [dll]
- ISReal interactive tool [source code] [exe]
- Benchmark [source code and expressions]

To use our library *real.dll*, you have to link *gmp.dll* and *real.dll*, and include the head file *real.h*. *real.h* defines a type *real* and contains the the following 12 functions for computing, and a function for output. Here, the angles involved in *calcs* are in radians, and that of *calcds* are in degrees.

- The following 4 functions first calculate the values of the expression in str, and then assigns the results to r.

1.1 real &calc(real &r, expr string4) &str); // correct to 10 decimal places

1.2 real &calc(real &r, expr string &str, int n); // correct to n decimal places

1.3 real &calcd(real &r, expr string &str); // correct to 10 decimal places

1.4 real &calcd(real &r, expr string &str, int n); // correct to n decimal places - The following 4 functions calculate the values of the expression in r, and the results are still in r.

2.1 real &calc(real &r); // correct to 10 decimal places

2.2 real &calc(real &r, int n); // correct to n decimal places

2.3 real &calcd(real &r); // correct to 10 decimal places

2.4 real &calcd(real &r, int n); // correct to n decimal places The following 4 functions calculate the values of the expression stored in the variable pointed to by str first, and then assigns the results

to r.

3.1 real &calc(real &r, char*str); // correct to 10 decimal places*str, int n); // correct to n decimal places

3.2 real &calc(real &r, char

3.3 real &calcd(real &r, char*str); // correct to 10 decimal places*str, int n); // correct to n decimal places

3.4 real &calcd(real &r, charThe ISReal GUI-based calculator demonstrates how to use real.dll.

We conduct an experimental study to check accuracy and scalability using following expressions:

f1=333.75b6+a2(11a2b2−b6−121b4−2)+5.5b8+a2b f2=((13−0.333333333333333235)+(13−0.333333333333333759)×0.008)×1020 f3=sin(2100) f4=eπ163√−262537412640768744 f5=2065−e65ln(20) f6=1340.7(tan(3×5.210.5) -tan(5.210.5)tan(π3 -5.210.5)tan(π3 +5.210.5)) f7=15.165−e65×ln(15.1)+20.260.2−e60.2×ln(20.2) f8=(arctan(10.55.4)−arcsin(10.55.41+(10.55.4)2√))×1053 f9=(cot(y)+cot(123.567)−sin(y+123.567)sin(y)×sin(123.567))×1050 *f10=(1+sin2(7.85395)1−sin2(7.85395)−1cos2(7.85395+568π))×10.940.9 f11=(1+cos2(6.28318)1−cos2(6.28318)−1sin2(6.28318+1200π))×11.9450.2 f12=sin(9.42477792)cos(9.42477792)−sin(9.4247779)1+cos(9.4247779) f13=(sin(c)×sin(d)tan(c)−sin(c+d)+sin(d−c)2)×20.136.54 f14=tan(x1)tan(x2 +9876π)cos(x1)cos(x2) +cos(x1+x2+98π)−cos(x1−x2)2 f15=tan(387674.1042493)−2×tan(387674.10424932)1−tan2(387674.10424932)

The results are shown in the above Table. We only present 10 significant digits of the results for C++ programs when they are sufficient to reveal inaccuracy. To analyze scalability of ISReal, we consider all the expressions `n`

, where `n`

ranges between `0`

and `500`

with step of `10`

. The results are shown in the following Figure.

- Shizhong Zhao. 2016. A reliable computing algorithm and its software ISReal for arithmetic expressions (in Chinese). SCIENTIA SINICA Informationis 46, 6 (2016), 698–713.
- Shizhong Zhao and Fu Song. 2017. A reliable computing algorithm and its software ISReal for arithmetic expressions. Technical Report. East China Normal University, ShanghaiTech University.
- Paul Zimmermann. 2010. Reliable computing with GNU MPFR. In International Congress on Mathematical Software. Springer, 42–
- Siegfried M. Rump. 1988. Reliability in Computing: The Role of Interval Methods in Scientific Computing. Boston: Academic Press, Chapter Algorithms for verified inclusion: theory and practice, 109–126.
- Jean-Michel Muller, Nicolas Brisebarre, Florent de Dinechin, Claude-Pierre Jeannerod, Vincent Lefèvre, Guillaume Melquiond, Nathalie Revol, Damien Stehlé, and Serge Torres. 2010. Handbook of Floating-Point Arithmetic. Birkhäuser.
- Eugene Loh and G. William Walster. 2002. Rump’s Example Revisited. Reliable Computing 8, 3 (2002), 245–248.

Copyright © 2017-2018 Fu Song and Shizhong Zhao.