Accuracy of Mathematical Functions in Single, Double, Extended Double and Quadruple Precision

Brian Gladman, Vincenzo Innocente, Paul Zimmermann · HAL (Le Centre pour la Communication Scientifique Directe) · 2021

Computer users, most of whom assume they are working with reliable routines, unwittingly accept results from functions where the accuracies vary significantly from one mathematical library to another, from one library function to another, and even over different argument intervals of the same function.[...] Users are not likely to demand an improved situation because most of them, having neither the time nor the inclination to test manufacturer-supplied software, do not know the problem exists.This paper contains the results of such tests of elementary functions from several computer companies.The data (see Table I) demonstrate that the industry does not satisfy the needs of those who require accurate and efficient mathematical software.These lines, written in 1984 by Black, Burton and Miller [5], are unfortunately still very true today.The IEEE 754 standard, even in its latest 2019 revision [13], does not require correctly rounded mathematical functions, it only recommends them.In turn, current mathematical libraries do not provide correct rounding, which is the best possible result.Thus, users might get different results with different libraries, or different versions of the same library.This can have dramatic consequences: for example missed collisions in the Large Hadron Collider [4] or reproducibility issues in neuroimaging [10].This document compares the accuracy of several mathematical libraries for the evaluation of mathematical functions, in single, double and quadruple precision (respectively binary32, binary64, and binary128 in the IEEE 754 standard), and also in the extended double format.For single precision, an exhaustive search is possible for univariate functions, thus the given values are upper bounds.For larger precisions or bivariate functions, since an exhaustive search is not possible with academic resources, we use a black-box algorithm that tries to locate the values with the largest error; the given values are only lower bounds, but comparing them can give an idea of the relative accuracy of different libraries.An interesting fact is that, for several functions, different libraries yield the same largest known error, for the exact same input value, which probably means they use the same code base.Note that some libraries document the maximal known errors [6,11].Today, at least for single precision and most double precision functions, it is known how to get correct rounding (for all rounding modes, not only for rounding to nearest) at very low cost, and reference implementations exist that outperform current libraries [22].

Read the paper · More papers on PaperTik