Abstract
Interval arithmetic is a well-known method for obtaining exact bounds on computational results even with inexact input data and numerical error introduced by finite-precision numerics. The posit format, which aims to surpass the precision efficiency of the conventional IEEE 754 floating-point format, is accompanied by valids, an adaption and generalisation of interval arithmetic. A calculation can be performed either with posits or with valids, yielding either an approximate result with high computational efficiency or rigorous lower and upper bounds on the result. However, Boolean relational predicates such as \(a < b\) are ambiguous when applied to overlapping intervals, leading to logical inconsistency no matter how the ambiguity is resolved. A numerical routine which has data-dependent branches can thus return incorrect results when applied to intervals or valids.
This paper proposes to define relational predicates for interval types as set-valued predicates instead of Boolean predicates. The proposed relational predicates are logically consistent and have intuitive projections to the two-element Boolean algebra. Using these predicates, we can express a calculation with data-dependent branches such that it can operate either on numbers or on intervals, while easily constraining interval-valued comparands by the branch condition. With such interval-aware code we can obtain either an approximate result or good interval bounds. We have developed a C++ library which implements the proposed concepts for traditional interval arithmetic. Furthermore, we have adapted it to a posit and valid implementation, demonstrating the viability of the concept with both traditional and more recent interval formats.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
References
IEEE Standard for Interval Arithmetic. IEEE Std 1788-2015, pp. 1–97 (2015). https://doi.org/10.1109/IEEESTD.2015.7140721
IEEE Standard for Floating-Point Arithmetic. IEEE Std 754-2019 (Revision of IEEE 754-2008), pp. 1–84 (2019). https://doi.org/10.1109/IEEESTD.2019.8766229
Standard for Posit Arithmetic (2022). Posit Working Group (2022)
Alefeld, G., Herzberger, J.: Introduction to Interval Computation. Academic Press (2012). Google-Books-ID: rUsX5x0OqUcC
Beutel, M.: Intervals: simple C++ library for interval arithmetic (2022). https://github.com/mbeutel/intervals
Brönnimann, H., Melquiond, G., Pion, S.: The design of the Boost interval arithmetic library. Theor. Comput. Sci. 351(1), 111–118 (2006). https://doi.org/10.1016/j.tcs.2005.09.062
Goualard, F.: GAOL (Not Just Another Interval Library) (2015). https://frederic.goualard.net/#research-software-gaol
Gustafson, J.L.: The End of Error: Unum Computing. Chapman and Hall/CRC, New York (2017). https://doi.org/10.1201/9781315161532
Gustafson, J.L.: Posit Arithmetic (2017)
Gustafson, J.L., Yonemoto, I.: Beating floating point at its own game: posit arithmetic. Supercomput. Front. Innov. 4(2), 16 (2017)
Hickey, T., Ju, Q., Van Emden, M.H.: Interval arithmetic: from principles to implementation. J. ACM 48(5), 1038–1068 (2001). https://doi.org/10.1145/502102.502106
Keszöcze, O., Brand, M., Witterauf, M., Heidorn, C., Teich, J.: Aarith: an arbitrary precision number library. In: Proceedings of the 36th Annual ACM Symposium on Applied Computing, SAC 2021, pp. 529–534. Association for Computing Machinery, New York (2021). https://doi.org/10.1145/3412841.3442085
Moore, R.E.: Interval Analysis (1966)
Moore, R.E., Kearfott, R.B., Cloud, M.J.: Introduction to interval analysis. Soc. Ind. Appl. Math. (2009). https://doi.org/10.1137/1.9780898717716
Schärtl, A.: Unums and Posits: A Replacement for IEEE 754 Floating Point? M.Sc. thesis, p. 111 (2021)
Sun Microsystems Inc.: C++ Interval Arithmetic Programming Reference (2001). Forte Developer 6 update 2 (Sun WorkShop 6 update 2)
Acknowledgements
We would like to thank Cornelis P. Dullemond and Charlotte Boys for valuable feedback and useful discussions, and Andreas Schärtl and Oliver Keszöcze for granting us access to their implementation of posits and valids. This work is funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) under Germany’s Excellence Strategy EXC 2181/1-390900948 (the Heidelberg STRUCTURES Excellence Cluster).
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
A Appendix
A Appendix
1.1 A.1 The Dependency Problem
The dependency problem [cf. 8 §16.2f], is a fundamental limitation of interval arithmetic which is rooted in the fact that correlations or dependencies between quantities cannot be represented in their bounding intervals, resulting in unnecessarily loose bounds. The problem becomes apparent already in the simple example given in Sect. 1.
Let us first define some elementary interval operations as
We only state the definitions for closed intervals for simplicity, but analogous definitions for half-open and open intervals are known.
Now, as per the Fundamental Theorem of Interval Arithmetic [1, 11], an interval extension of the algebraic expression
can be obtained as the composition of interval extensions of the constituting operations,
where \(X \equiv [X^-,X^+]\) denotes an interval. Inserting the interval \(X = [0,1]\) into Eq. (33), we obtain
However, if we first recast the expression in Eq. (32) as
then inserting \(X = [0,1]\) into its syntactic interval extension \(\left( X - 1\right) ^2 - 1\) yields the much narrower and, in fact, optimal interval bounds \([-1,0]\). The two scalar expressions of Eqs. (32) and (35) may be equivalent, but their syntactic interval extensions are not.
1.2 A.2 Code Dependencies
![figure de](http://media.springernature.com/lw685/springer-static/image/chp%3A10.1007%2F978-3-031-32180-1_3/MediaObjects/541825_1_En_3_Figde_HTML.png)
To avoid redundancy, the
statements and some other declarations needed to compile the code were omitted in our listings. Listing 1.9 shows the statements and declarations that need to be prepended to each of the listings in this paper.
1.3 A.3 Piecewise Linear Interpolation
The linear interpolation example in Listing 1.8 can be generalised to a piecewise linear interpolation between ordered sampling points \(x_1,\ldots ,x_n\) and associated sampling values \(y_1,\ldots ,y_n\), given in Listing 1.10. By taking advantage of the monotonically increasing order of sampling points, \(x_i < x_{i+1} \,\forall i \in \{1,\ldots ,n-1\}\), for a given value x we can locate the appropriate segment i in \(\mathcal {O}(\log n)\) steps with binary search using the
algorithm from the C++ Standard Library.
To make piecewise linear interpolation interval-aware, as has been done in Listing 1.11, we use the
implementation from the intervals library. When called with an interval argument, it returns a set of predicates
and an interval of lower-bound iterators
. An interval of segment indices
can then be obtained by subtraction. By iterating over the elements
of the interval of overlapping segment indices
and by constraining the argument
with the segment predicate
of the j-th segment, we can compute all piecewise contributions to the result. The same code can also be instantiated for normal floating-point types, in which case it is equivalent to the code in Listing 1.10 because the loop over j collapses to a single iteration with \(j = i\).
![figure dp](http://media.springernature.com/lw685/springer-static/image/chp%3A10.1007%2F978-3-031-32180-1_3/MediaObjects/541825_1_En_3_Figdp_HTML.png)
![figure dq](http://media.springernature.com/lw685/springer-static/image/chp%3A10.1007%2F978-3-031-32180-1_3/MediaObjects/541825_1_En_3_Figdq_HTML.png)
Rights and permissions
Copyright information
© 2023 The Author(s), under exclusive license to Springer Nature Switzerland AG
About this paper
Cite this paper
Beutel, M., Strzodka, R. (2023). A Paradigm for Interval-Aware Programming. In: Gustafson, J., Leong, S.H., Michalewicz, M. (eds) Next Generation Arithmetic. CoNGA 2023. Lecture Notes in Computer Science, vol 13851. Springer, Cham. https://doi.org/10.1007/978-3-031-32180-1_3
Download citation
DOI: https://doi.org/10.1007/978-3-031-32180-1_3
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-031-32179-5
Online ISBN: 978-3-031-32180-1
eBook Packages: Computer ScienceComputer Science (R0)