ICNPAA, ICNPAA WORLD CONGRESS 2020

Font Size: 
USING KOTLIN PROGRAMMING LANGUAGE FOR INTERVAL ARITHMETIC
Andrei Uskov

Last modified: 2023-05-15

Abstract


Interval arithmetic has been invented as late as 60s [1] and was considered to be a valuable tool allowing to perform self-validated numerical calculations. According to the Fundamental Theorem of Interval Arithmetic, once all inputs of a calculated function are treated as intervals containing exact value, the calculation result contains the exact value of the calculated function [2]. Due to high overhead of service calculations the interval arithmetic was mainly of theoretical interest but during the last decade several standards (IEEE 1788-2008, IEEE 1788-2015, IEEE 1788.1-2017) covering interval arithmetic were released. It led to a progress in development of application libraries. At the moment several libraries for different programming languages are available libieeep1788, JInterval, GNU Octave are among them. Unfortunately GNU Octave appears to be the only maintainable library at the moment [3].

In the present work the library implementing subset of IEEE 1788.1-2017 written Kotlin Multiplatform is presented. Kotlin Multiplatform gives opportunity to compile the code into JVM byte code, JavaScript code or native byte code. Automatic type inference implemented in Kotlin allows to write compact easy to read code. Samples of code in C++ and Kotlin are presented below:

 

C++/libieeep1788

using I = p1788::infsup::interval<T, p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor>;

I<double> a(-1.0,1.0);

I<double> b(1.0,2.0);

I<double> c = a + b;

 

Kotlin

val a = 0.0 withError 1.0

val b = 1.0 intervalTo 2.0

val c = a+b

The intrinsical performance problems of interval arithmetic are avoided using correct in terms of IEEE 1788 interval calculation instead of accurate of tight (in terms of IEEE 1788) rules which are requested by a standard. This approach allows to achieve a better performance without losing correctness in numerous applied tasks.

 

References

1. R.E. Moore, Interval analysis. Prentice-Hall, 1966

2. N. Revol, Introduction to the IEEE 1788-2015 Standard for Interval Arithmetic. Workshop of CAV 2017. Heidelberg, Germany, 2017

3. N Revol. The MPFI Library: Towards IEEE 1788-2015 Compliance. PPAM 2019, Bialystok, Poland, 2019.