skip to main content
research-article

Trustworthy numerical computation in Scala

Published:22 October 2011Publication History
Skip Abstract Section

Abstract

Modern computing has adopted the floating point type as a default way to describe computations with real numbers. Thanks to dedicated hardware support, such computations are efficient on modern architectures, even in double precision. However, rigorous reasoning about the resulting programs remains difficult. This is in part due to a large gap between the finite floating point representation and the infinite-precision real-number semantics that serves as the developers' mental model. Because programming languages do not provide support for estimating errors, some computations in practice are performed more and some less precisely than needed.

We present a library solution for rigorous arithmetic computation. Our numerical data type library tracks a (double) floating point value, but also a guaranteed upper bound on the error between this value and the ideal value that would be computed in the real-value semantics. Our implementation involves a set of linear approximations based on an extension of affine arithmetic. The derived approximations cover most of the standard mathematical operations, including trigonometric functions, and are more comprehensive than any publicly available ones. Moreover, while interval arithmetic rapidly yields overly pessimistic estimates, our approach remains precise for several computational tasks of interest. We evaluate the library on a number of examples from numerical analysis and physical simulations. We found it to be a useful tool for gaining confidence in the correctness of the computation.

References

  1. DocWeb - Java SE 6 - java.lang.Math. http://doc.java.sun.com/DocWeb/#r/Java SE 6/java.lang.Math/columnMain.Google ScholarGoogle Scholar
  2. J. Stolfi's general-purpose C libraries. http://www.ic.unicamp.br/~stolfi/EXPORT/software/c/ Index.html#libaa, 2005.Google ScholarGoogle Scholar
  3. aaflib - An Affine Arithmetic C+ Library. http://aaflib.sourceforge.net/, 2010.Google ScholarGoogle Scholar
  4. The Computer Language Benchmarks Game. http://shootout.alioth.debian.org/, Jan 2011.Google ScholarGoogle Scholar
  5. B. Akbarpour and L. C. Paulson. MetiTarski: An Automatic Theorem Prover for Real-Valued Special Functions. J. Autom. Reason., 44(3), 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. A. Ayad and C. Marché. Multi-Prover Verification of Floating-Point Programs. In IJCAR, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. T. Ball, E. Bounimova, R. Kumar, and V. Levin. Slam2: Static driver verification with under 4% false alarms. In FMCAD, pages 35--42, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. S. Boldo, J.-C. Filliâtre, and G. Melquiond. Combining Coq and Gappa for Certifying Floating-Point Programs. In CICM, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. S. Boldo and T. M. T. Nguyen. Hardware-independent proofs of numerical programs. In Proceedings of the Second NASA Formal Methods Symposium, 2010.Google ScholarGoogle Scholar
  10. B. Botella, A. Gotlieb, and C. Michel. Symbolic execution of floating-point computations. Softw. Test. Verif. Reliab., 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. A. Brillout, D. Kroening, and T. Wahl. Mixed Abstractions for Floating-Point Arithmetic. In FMCAD, 2009.Google ScholarGoogle ScholarCross RefCross Ref
  12. S. Chaudhuri, S. Gulwani, and R. Lublinerman. Continuity analysis of programs. In POPL, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. L. Chen, A. Miné, J. Wang, and P. Cousot. A Sound Floating-Point Polyhedra Abstract Domain. In APLAS, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. P. Cousot, R. Cousot, J. Feret, L. Mauborgne, A. Miné, D. Monniaux, and X. Rival. The ASTRÉE Analyser. In ESOP, 2005.Google ScholarGoogle Scholar
  15. Manuvir Das, Sorin Lerner, and Mark Seigle. ESP: Path-sensitive program verification in polynomial time. 2002.Google ScholarGoogle Scholar
  16. M. Davis. DoubleDouble.java. http://tsusiatsoftware.net/dd/main.html.Google ScholarGoogle Scholar
  17. L. H. de Figueiredo and J. Stolfi. Self-Validated Numerical Methods and Applications. IMPA/CNPq, Brazil, 1997.Google ScholarGoogle Scholar
  18. L. H. de~Figueiredo and J. Stolfi. Affine Arithmetic: Concepts and Applications. Numerical Algorithms, 2004.Google ScholarGoogle Scholar
  19. Isil Dillig, Thomas Dillig, and Alex Aiken. Sound, complete and scalable path-sensitive analysis. In PLDI, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. A. G. Ershov and T. P. Kashevarova. Interval Mathematical Library Based on Chebyshev and Taylor Series Expansion. Reliable Computing, 11, 2005.Google ScholarGoogle Scholar
  21. C.F. Fang, Tsuhan C., and R.A. Rutenbar. Floating-point error analysis based on affine arithmetic. In ICASSP, 2003.Google ScholarGoogle ScholarCross RefCross Ref
  22. A.A. Gaffar, O. Mencer, and W. Luk. Unifying bit-width optimisation for fixed-point and floating-point designs. In Field-Programmable Custom Computing Machines, 2004. FCCM 2004. 12th Annual IEEE Symposium on, pages 79 -- 88, april 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. D. Goldberg. What every computer scientist should know about floating-point arithmetic. ACM Comput. Surv., 23(1), 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. J. Gosling, B. Joy, G. Steele, and G. Bracha. Java(TM) Language Specification, The 3rd Edition. Addison-Wesley, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. E. Goubault and S. Putot. Static Analysis of Finite Precision Computations. In VMCAI, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Ch. Grimm, W. Heupke, and K. Waldschmidt. Refinement of Mixed-Signal Systems with Affine Arithmetic. In DATE, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. J. Harrison. Formal Verification at Intel. In LICS, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. L. Hatton and A. Roberts. How Accurate is Scientific Software? IEEE Trans. Softw. Eng., 20, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. F. Ivancic, M. K. Ganai, S. Sankaranarayanan, and A. Gupta. Numerical stability analysis of floating-point computations using software model checking. In MEMOCODE, 2010.Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. B. Jeannet and A. Miné. Apron: A Library of Numerical Abstract Domains for Static Analysis. In CAV, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. F. Jézéquel and J.-M. Chesneaux. CADNA: a library for estimating round-off error propagation. Computer Physics Communications, 178(12), 2008.Google ScholarGoogle Scholar
  32. J. Jiang, W. Luk, and D. Rueckert. FPGA-Based Computation of Free-Form Deformations. In Field - Programmable Logic and Applications. 2003.Google ScholarGoogle Scholar
  33. W. Kahan. Miscalculating Area and Angles of a Needle-like Triangle. Technical report, University of California Berkeley, 2000.Google ScholarGoogle Scholar
  34. A.B. Kinsman and N. Nicolici. Finite Precision bit-width allocation using SAT-Modulo Theory. In DATE, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Etienne Kneuss, Philippe Suter, and Viktor Kuncak. Runtime instrumentation for precise flow-sensitive type analysis. In International Conference on Runtime Verification, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Viktor Kuncak, Patrick Lam, Karen Zee, and Martin Rinard. Modular pluggable analyses for data structure consistency. IEEE Transactions on Software Engineering, 32(12), December 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. D.-U. Lee, A. A. Gaffar, R. C. C. Cheung, O. Mencer, W. Luk, and G. A. Constantinides. Accuracy-Guaranteed Bit-Width Optimization. IEEE Trans. on CAD of Integrated Circuits and Systems, 25(10), 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. X. Leroy. Verified squared: does critical software deserve verified tools? In POPL, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. M. D. Linderman, M. Ho, D. L. Dill, T. H. Meng, and G. P. Nolan. Towards program optimization through automated analysis of numerical precision. In CGO, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. T. Lindholm and F. Yellin. Java Virtual Machine Specification. Addison-Wesley Longman Publishing Co., Inc., 2nd edition, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. R. Longbottom. Whetstone Benchmark Java Version. http://www.roylongbottom.org.uk/online/whetjava.html, 1997.Google ScholarGoogle Scholar
  42. R. Majumdar and I. Saha. Symbolic Robustness Analysis. In IEEE Real-Time Systems Symposium, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. M. Martel. An overview of semantics for the validation of numerical programs. In VMCAI, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. R. Martin, H. Shou, I. Voiculescu, A. Bowyer, and G. Wang. Comparison of interval methods for plotting algebraic curves. Comput. Aided Geom. Des., 19(7), 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. D. Monniaux. The pitfalls of verifying floating-point computations. ACM Trans. Program. Lang. Syst., 30(3), 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. J. S. Moore, T. W. Lynch, and M. Kaufmann. A Mechanically Checked Proof of the AMD5 K86 Floating Point Division Program. IEEE Trans. Computers, 47(9), 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. R.E. Moore. Interval Analysis. Prentice-Hall, 1966.Google ScholarGoogle Scholar
  48. M. Odersky, L. Spoon, and B. Venners. Programming in Scala: a comprehensive step-by-step guide. Artima Press, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. R. Pozo and B. R. Miller. Java SciMark 2.0. http://math.nist.gov/scimark2/about.html, 2004.Google ScholarGoogle Scholar
  50. D. M. Priest. Algorithms for Arbitrary Precision Floating Point Arithmetic. In Proceedings of the 10th Symposium on Computer Arithmetic, 1991.Google ScholarGoogle ScholarCross RefCross Ref
  51. Scala Programming~Language Blog. '==' and equals. http://scala-programming-language.1934581.n4.nabble.com/and-equals-td22%61488.html, June 2010.Google ScholarGoogle Scholar
  52. T. Rompf and M. Odersky. Lightweight modular staging: a pragmatic approach to runtime code generation and compiled DSLs. In GPCE, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  53. P. M. Rondon, M. Kawaguci, and R. Jhala. Liquid types. In PLDI, pages 159--169, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  54. D. M. Russinoff. A Mechanically Checked Proof of Correctness of the AMD K5 Floating Point Square Root Microcode. Formal Methods in System Design, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  55. R. A. Rutenbar, C. F. Fang, M. Püschel, and T. Chen. Toward efficient static analysis of finite-precision effects in DSP applications via affine arithmetic modeling. In DAC, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  56. T. R. Scavo and J. B. Thoo. On the Geometry of Halley's Method. The American Mathematical Monthly, 102(5), 1995.Google ScholarGoogle Scholar
  57. H. Shou, R.R. Martin, I. Voiculescu, A. Bowyer, and G. Wang. Affine Arithmetic in Matrix Form for Polynomial Evaluation and Algebraic Curve Drawing. Progress in Natural Science, 12, 2002.Google ScholarGoogle Scholar
  58. IEEE~Computer Society. IEEE Standard for Floating-Point Arithmetic. IEEE Std 754--2008, 2008.Google ScholarGoogle Scholar
  59. J. Walker. fbench - Trigonometry Intense Floating Point Benchmark. http://www.fourmilab.ch/fbench/fbench.html, 2007.Google ScholarGoogle Scholar
  60. J. White. Fbench.java. http://code.google.com/p/geo-reminder/source/browse/trunk/benchmark-and%roid/src/com/benchmark/suite/Fbench.java?r=108, 2005.Google ScholarGoogle Scholar
  61. L. Zhang, Y. Zhang, and W. Zhou. Tradeoff between Approximation Accuracy and Complexity for Range Analysis using Affine Arithmetic. Journal of Signal Processing Systems, 61, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Trustworthy numerical computation in Scala

            Recommendations

            Comments

            Login options

            Check if you have access through your login credentials or your institution to get full access on this article.

            Sign in

            Full Access

            • Published in

              cover image ACM SIGPLAN Notices
              ACM SIGPLAN Notices  Volume 46, Issue 10
              OOPSLA '11
              October 2011
              1063 pages
              ISSN:0362-1340
              EISSN:1558-1160
              DOI:10.1145/2076021
              Issue’s Table of Contents
              • cover image ACM Conferences
                OOPSLA '11: Proceedings of the 2011 ACM international conference on Object oriented programming systems languages and applications
                October 2011
                1104 pages
                ISBN:9781450309400
                DOI:10.1145/2048066

              Copyright © 2011 ACM

              Publisher

              Association for Computing Machinery

              New York, NY, United States

              Publication History

              • Published: 22 October 2011

              Check for updates

              Qualifiers

              • research-article

            PDF Format

            View or Download as a PDF file.

            PDF

            eReader

            View online with eReader.

            eReader
            About Cookies On This Site

            We use cookies to ensure that we give you the best experience on our website.

            Learn more

            Got it!