Metalibm: A Mathematical Functions Code Generator

  • Olga Kupriianova
  • Christoph Lauter
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8592)


There are several different libraries with code for mathematical functions such as exp, log, sin, cos, etc. They provide only one implementation for each function. As there is a link between accuracy and performance, that approach is not optimal. Sometimes there is a need to rewrite a function’s implementation with the respect to a particular specification.

In this paper we present a code generator for parametrized implementations of mathematical functions. We discuss the benefits of code generation for mathematical libraries and present how to implement mathematical functions. We also explain how the mathematical functions are usually implemented and generalize this idea for the case of arbitrary function with implementation parameters.

Our code generator produces C code for parametrized functions within a known scheme: range reduction (domain splitting), polynomial approximation and reconstruction. This approach can be expanded to generate code for black-box functions, e.g. defined only by differential equations.


code generation elementary functions mathematical libraries 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Loosemore, S., Stallman, R.M., et al.: The GNU C Library Reference Manual for version 2.19, Free Software Foundation, Inc.Google Scholar
  2. 2.
    Daramy-Loirat, C., Defour, D., de Dinechin, F., et al.: CR-LIBM. A library of correctly rounded elementary functions in double-precision, user’s manual (2013)Google Scholar
  3. 3.
    IEEE Computer Society, IEEE Standard for Floating-Point Arithmetic, IEEE Standard 754-2008 (August 2008)Google Scholar
  4. 4.
    Muller, J.-M.: Elementary Functions: Algorithms and Implementation. Birkhauser Boston, Inc., Secaucus (1997)CrossRefzbMATHGoogle Scholar
  5. 5.
    Chevillard, S., Joldeş, M., Lauter, C.: Sollya: An Environment for the Development of Numerical Codes. In: Fukuda, K., van der Hoeven, J., Joswig, M., Takayama, N. (eds.) ICMS 2010. LNCS, vol. 6327, pp. 28–31. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  6. 6.
    Chevillard, S., Lauter, C., Joldeş, M.: Users manual for the Sollya tool, Release 4.0 (May 2013)Google Scholar
  7. 7.
    de Dinechin, F., Lauter, C., Melquiond, G.: Certifying the Floating-Point Implementation of an Elementary Function Using Gappa. IEEE Transactions on Computers 60, 242–253 (2011)CrossRefGoogle Scholar
  8. 8.
    Muller, J.-M., Brisebarre, N., de Dinechin, F., et al.: Handbook of Floating-Point Arithmetic. Birkhäuser (2010)Google Scholar
  9. 9.
    Chevillard, S.: Évaluation efficace de fonctions numériques. Outils et exemples, PhD Thesis, ENS de Lyon (2009)Google Scholar
  10. 10.
    Tang, P.T.P.: Table-driven implementation of the exponential function in IEEE floating-point arithmetic. ACM Transactions on Mathematical Software 18(2), 211–222 (1989)CrossRefGoogle Scholar
  11. 11.
    Lauter, C.: Arrondi correct de fonctions mathématiques, PhD Thesis, ENS de Lyon (2008)Google Scholar
  12. 12.
    Schewchuk, J.R.: Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates. Discrete & Computational Geometry (1997)Google Scholar
  13. 13.
    de Dinechin, F., Defour, D., Lauter, C.: Fast correct rounding of elementary functions in double precision using double-extended arithmetic, Research report, ENS de Lyon (2004)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2014

Authors and Affiliations

  • Olga Kupriianova
    • 1
  • Christoph Lauter
    • 1
  1. 1.Sorbonne Universités, UPMC Univ. Paris 06, UMR 7606, LIP6ParisFrance

Personalised recommendations