Skip to main content

A Paradigm for Interval-Aware Programming

  • Conference paper
  • First Online:
Next Generation Arithmetic (CoNGA 2023)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 13851))

Included in the following conference series:

  • 263 Accesses

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

References

  1. IEEE Standard for Interval Arithmetic. IEEE Std 1788-2015, pp. 1–97 (2015). https://doi.org/10.1109/IEEESTD.2015.7140721

  2. 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

  3. Standard for Posit Arithmetic (2022). Posit Working Group (2022)

    Google Scholar 

  4. Alefeld, G., Herzberger, J.: Introduction to Interval Computation. Academic Press (2012). Google-Books-ID: rUsX5x0OqUcC

    Google Scholar 

  5. Beutel, M.: Intervals: simple C++ library for interval arithmetic (2022). https://github.com/mbeutel/intervals

  6. 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

    Article  MathSciNet  MATH  Google Scholar 

  7. Goualard, F.: GAOL (Not Just Another Interval Library) (2015). https://frederic.goualard.net/#research-software-gaol

  8. Gustafson, J.L.: The End of Error: Unum Computing. Chapman and Hall/CRC, New York (2017). https://doi.org/10.1201/9781315161532

  9. Gustafson, J.L.: Posit Arithmetic (2017)

    Google Scholar 

  10. Gustafson, J.L., Yonemoto, I.: Beating floating point at its own game: posit arithmetic. Supercomput. Front. Innov. 4(2), 16 (2017)

    Google Scholar 

  11. 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

    Article  MathSciNet  MATH  Google Scholar 

  12. 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

  13. Moore, R.E.: Interval Analysis (1966)

    Google Scholar 

  14. 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

    Article  MATH  Google Scholar 

  15. Schärtl, A.: Unums and Posits: A Replacement for IEEE 754 Floating Point? M.Sc. thesis, p. 111 (2021)

    Google Scholar 

  16. Sun Microsystems Inc.: C++ Interval Arithmetic Programming Reference (2001). Forte Developer 6 update 2 (Sun WorkShop 6 update 2)

    Google Scholar 

Download references

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

Authors

Corresponding author

Correspondence to Moritz Beutel .

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

$$\begin{aligned}{}[X^-,X^+]^2&\, {:}{=}\, {\left\{ \begin{array}{ll} \big [0, \left( \max \left\{ -X^-, X^+\right\} \right) ^2\big ] &{} \text {if } 0 \in X \\ \big [\left( X^-\right) ^2, \left( X^+\right) ^2\big ] &{} \text {if } X^- > 0 \\ \big [\left( X^+\right) ^2, \left( X^-\right) ^2\big ] &{} \text {if } X^+ < 0 \end{array}\right. } \end{aligned}$$
(28)
$$\begin{aligned} a [X^-,X^+]&\, {:}{=}\, {\left\{ \begin{array}{ll} \big [a X^-, a X^+\big ] &{} \text {if } a \ge 0 \\ \big [a X^+, a X^-\big ] &{} \text {if } a < 0 \end{array}\right. } \end{aligned}$$
(29)
$$\begin{aligned} -[X^-, X^+]&\, {:}{=}\, [-X^+, -X^-] \end{aligned}$$
(30)
$$\begin{aligned} X + Y&\, {:}{=}\, [X^- + Y^-, X^+ + Y^+]. \end{aligned}$$
(31)

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

$$\begin{aligned} x^2 - 2 x \end{aligned}$$
(32)

can be obtained as the composition of interval extensions of the constituting operations,

$$\begin{aligned} X^2 - 2 X , \end{aligned}$$
(33)

where \(X \equiv [X^-,X^+]\) denotes an interval. Inserting the interval \(X = [0,1]\) into Eq. (33), we obtain

$$\begin{aligned}{}[0,1]^2 - 2 [0,1]&= [0,1] - [0,2] = [-2, 1]. \end{aligned}$$
(34)

However, if we first recast the expression in Eq. (32) as

$$\begin{aligned} (x - 1)^2 - 1, \end{aligned}$$
(35)

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

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
figure dq

Rights and permissions

Reprints and permissions

Copyright information

© 2023 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

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)

Publish with us

Policies and ethics