Some of the mathematical functions of the standard C library have been tested on worst cases for correct rounding in double precision. The following table gives the ratio or the number of incorrect roundings for various machines, in the rounding to nearest mode. Greyed cells (or with brackets) contain a link to explanations below the table. This table is quite old (latest changes in 2005, 5 additions in 2006 and 2 in 2009), but this gives an idea about the problem.
Function | exp |
log |
exp2 |
log2 |
exp10 |
log10 |
sinh |
asinh |
cosh |
acosh |
sin |
asin |
cos |
acos |
tan |
atan |
isq |
isqrt |
cube |
cbrt |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Number of tests | 2268 | 2813 | 1145 | 929 | 1668 | 1883 | 2215 | 2262 | 2026 | 1877 | 1611 | 1655 | 1576 | 1569 | 1706 | 1735 | 58 | 78 | 150 | 138 |
49 % | 43 % | 52 % | 46 % | 49 % | 100 % | 50 % | 41 % | 100 % | 49 % | 100 % | 83 % | 100 % | 100 % | 55 % | 51 % | |||||
49 % | 43 % | 48 % | 45 % | 52 % | 46 % | 49 % | 52 % | 50 % | 41 % | 51 % | 49 % | 49 % | 83 % | 52 % | 50 % | 55 % | 51 % | 53 % | 43 % | |
49 % | 43 % | 48 % | 45 % | 52 % | 46 % | 52 % | 52 % | 50 % | 41 % | 51 % | 49 % | 49 % | 83 % | 52 % | 50 % | 55 % | 51 % | 53 % | 43 % | |
49 % | 43 % | 46 % | 51 % | 49 % | 46 % | 49 % | 51 % | 50 % | 49 % | 50 % | 52 % | 50 % | 53 % | 51 % | 51 % | 58 % | ||||
49 % | 43 % | 46 % | 51 % | 82 % | 46 % | 86 % | 51 % | 51 % | 49 % | 95 % | 52 % | 50 % | 53 % | 51 % | ||||||
49 % | 43 % | 46 % | 51 % | 50 % | 46 % | 50 % | 51 % | 51 % | 49 % | 95 % | 52 % | 50 % | 53 % | 51 % | 51 % | 58 % | ||||
49 % | 43 % | 48 % | 44 % | 52 % | 47 % | 49 % | 51 % | 50 % | 41 % | 51 % | 49 % | 49 % | 83 % | 52 % | 50 % | 55 % | 51 % | 53 % | 43 % | |
49 % | 42 % | 48 % | 44 % | 52 % | 48 % | 49 % | 50 % | 50 % | 41 % | 51 % | 49 % | 49 % | 83 % | 51 % | 50 % | 55 % | 51 % | 53 % | 43 % | |
49 % | 31 % | 46 % | 29 % | 41 % | 50 % | 50 % | 50 % | 49 % | 49 % | 48 % | 44 % | 50 % | 46 % | 44 % | 41 % | 50 % | 47 % | 58 % | ||
49 % | 30 % | 70 % | 48 % | 51 % | 50 % | 46 % | 48 % | 49 % | 48 % | 45 % | 30 % | 51 % | 51 % | 53 % | 51 % | |||||
49 % | 30 % | 51 % | 50 % | 51 % | 50 % | 46 % | 48 % | 49 % | 48 % | 45 % | 30 % | 51 % | 51 % | 53 % | 51 % | |||||
50 % | 30 % | 48 % | 51 % | 50 % | 47 % | 48 % | 49 % | 47 % | 45 % | 29 % | 51 % | 51 % | 53 % | 51 % | ||||||
50 % | 31 % | 50 % | 47 % | 50 % | 49 % | 54 % | 50 % | 48 % | 49 % | 49 % | 50 % | 50 % | 45 % | 45 % | 43 % | 57 % | ||||
50 % | 31 % | 51 % | 48 % | 51 % | 48 % | 53 % | 49 % | 48 % | 51 % | 49 % | 49 % | 50 % | 55 % | 60 % | 49 % | 58 % | ||||
51 % | 31 % | 47 % | 42 % | 44 % | 47 % | 47 % | 45 % | 51 % | 51 % | 47 % | 50 % | 41 % | 49 % | 46 % | 48 % | 55 % | 45 % | 51 % | ||
51 % | 31 % | 44 % | 47 % | 47 % | 45 % | 51 % | 51 % | 47 % | 50 % | 41 % | 49 % | 46 % | 48 % | 55 % | ||||||
51 % | 31 % | 44 % | 47 % | 47 % | 45 % | 51 % | 51 % | 47 % | 50 % | 41 % | 49 % | 46 % | 48 % | 55 % | 45 % | 51 % | ||||
51 % | 31 % | 44 % | 47 % | 46 % | 45 % | 50 % | 51 % | 47 % | 50 % | 41 % | 49 % | 46 % | 48 % | 55 % | 45 % | 51 % | ||||
51 % | 31 % | 47 % | 42 % | 44 % | 47 % | 46 % | 45 % | 50 % | 51 % | 47 % | 50 % | 41 % | 49 % | 46 % | 48 % | 55 % | 45 % | 51 % | ||
50 % | 30 % | 46 % | 38 % | 50 % | 42 % | 50 % | 50 % | 46 % | 49 % | 48 % | 47 % | 48 % | 29 % | 50 % | 45 % | 48 % | 47 % | |||
50 % | 30 % | 46 % | 38 % | 50 % | 42 % | 50 % | 50 % | 47 % | 49 % | 48 % | 47 % | 48 % | 29 % | 50 % | 45 % | 48 % | 47 % | 49 % | 62 % | |
49 % | 30 % | 52 % | 50 % | 51 % | 50 % | 46 % | 48 % | 49 % | 47 % | 45 % | 28 % | 50 % | 51 % | 53 % | 51 % | |||||
43 % | 52 % | 52 % | 50 % | 66 % | 46 % | 49 % | 50 % | 40 % | 49 % | 51 % | 50 % | 50 % | 41 % | 46 % | 46 % | 55 % | 54 % | 48 % | 46 % | |
47 % | 43 % | 46 % | 46 % | 47 % | 49 % | 46 % | 44 % | 52 % | 49 % | 50 % | 39 % | 49 % | 41 % | 59 % | 49 % | |||||
47 % | 43 % | 46 % | 46 % | 44 % | 49 % | 38 % | 44 % | 52 % | 49 % | 50 % | 39 % | 49 % | 41 % | 59 % | 49 % | 45 % | 43 % | |||
50 % | 30 % | 47 % | 49 % | 51 % | 48 % | 50 % | 50 % | 46 % | 49 % | 49 % | 47 % | 50 % | 29 % | 51 % | 50 % | 57 % | 53 % | 40 % | 58 % | |
42 % | 34 % | 66 % | 45 % | 80 % | 50 % | 48 % | 49 % | 47 % | 50 % | 50 % | 37 % | 50 % | 44 % | 59 % | 59 % | |||||
42 % | 34 % | 51 % | 50 % | 66 % | 45 % | 80 % | 50 % | 48 % | 49 % | 47 % | 50 % | 50 % | 37 % | 50 % | 44 % | 59 % | 59 % | |||
0 | 0 | 51 % | 50 % | 66 % | 47 % | 45 % | 50 % | 45 % | 49 % | 0 | 0 | 5 | 17 % | 0 | 0 | 0 | 0 | 0 | 62 % | |
0 | 0 | 51 % | 50 % | 66 % | 47 % | 45 % | 50 % | 45 % | 49 % | 0 | 0 | 5 | 17 % | 0 | 28 % | 0 | 0 | |||
0 | 0 | 51 % | 50 % | 66 % | 47 % | 45 % | 50 % | 45 % | 49 % | 0 | 0 | 0 | 17 % | 0 | 28 % | 0 | 0 | |||
0 | 0 | 51 % | 50 % | 66 % | 47 % | 45 % | 50 % | 45 % | 49 % | 0 | 0 | 0 | 17 % | 0 | 28 % | 0 | 0 | 0 | 62 % | |
0 | 0 | 51 % | 50 % | 66 % | 47 % | 45 % | 50 % | 45 % | 49 % | 0 | 0 | 0 | 17 % | 0 | 0 | 0 | 0 | 0 | 62 % | |
0 | 0 | 52 % | 50 % | 66 % | 47 % | 45 % | 50 % | 45 % | 49 % | 0 | 0 | 0 | 17 % | 0 | 0 | 0 | 0 | 0 | 62 % | |
0 | 0 | 52 % | 50 % | 66 % | 48 % | 45 % | 50 % | 45 % | 49 % | 0 | 0 | 0 | 17 % | 0 | 0 | 0 | 0 | 0 | 62 % | |
0 | 5 % | 52 % | 50 % | 66 % | 48 % | 45 % | 50 % | 45 % | 49 % | 0 | 0 | 0 | 17 % | 0 | 0 | 0 | 0 | 0 | 62 % |
More recent results:
Function | exp |
log |
expm1 |
log1p |
exp2 |
log2 |
exp10 |
log10 |
sinh |
asinh |
cosh |
acosh |
tanh |
atanh |
sin |
asin |
cos |
acos |
tan |
atan |
isq |
isqrt |
cube |
cbrt |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Number of tests | 2268 | 2813 | 7578 | 7550 | 1145 | 929 | 1668 | 1883 | 2215 | 2262 | 2026 | 1877 | 1852 | 1552 | 1611 | 1655 | 1576 | 1569 | 1706 | 1735 | 58 | 78 | 150 | 138 |
49 % | 43 % | 50 % | 52 % | 48 % | 44 % | 52 % | 47 % | 51 % | 50 % | 49 % | 50 % | 52 % | 51 % | 51 % | 49 % | 49 % | 40 % | 52 % | 50 % | 53 % | 51 % | 49 % | 49 % | |
49 % | 43 % | 50 % | 52 % | 48 % | 44 % | 52 % | 47 % | 51 % | 50 % | 49 % | 48 % | 52 % | 51 % | 51 % | 49 % | 49 % | 40 % | 52 % | 50 % | 53 % | 51 % | 49 % | 49 % | |
49 % | 43 % | 44 % | 52 % | 48 % | 50 % | 46 % | 51 % | 50 % | 46 % | 49 % | 50 % | 51 % | 51 % | 49 % | 49 % | 83 % | 52 % | 50 % | 53 % | 47 % | 51 % | 58 % | ||
49 % | 43 % | 44 % | 52 % | 48 % | 45 % | 46 % | 51 % | 50 % | 46 % | 49 % | 50 % | 51 % | 49 % | 49 % | 45 % | 83 % | 51 % | 50 % | 53 % | 51 % | 51 % | 58 % | ||
50 % | 30 % | 44 % | 48 % | 48 % | 37 % | 42 % | 51 % | 50 % | 47 % | 48 % | 50 % | 51 % | 49 % | 47 % | 44 % | 29 % | 51 % | 51 % | 53 % | 47 % | 51 % | 56 % | ||
48 % | 31 % | 47 % | 49 % | 49 % | 30 % | 40 % | 48 % | 50 % | 45 % | 49 % | 46 % | 50 % | 49 % | 52 % | 43 % | 47 % | 51 % | 52 % | 53 % | 63 % | 41 % | 47 % | ||
50 % | 31 % | 44 % | 48 % | 47 % | 51 % | 51 % | 49 % | 50 % | 50 % | 46 % | 49 % | 50 % | 50 % | 49 % | 47 % | 48 % | 29 % | 50 % | 48 % | 57 % | 53 % | 40 % | 43 % | |
50 % | 30 % | 44 % | 48 % | 47 % | 50 % | 51 % | 48 % | 50 % | 50 % | 46 % | 49 % | 50 % | 50 % | 49 % | 47 % | 50 % | 29 % | 51 % | 50 % | 57 % | 53 % | 40 % | 43 % | |
50 % | 30 % | 44 % | 48 % | 47 % | 49 % | 51 % | 48 % | 50 % | 50 % | 46 % | 49 % | 50 % | 50 % | 49 % | 47 % | 47 % | 29 % | 50 % | 48 % | 57 % | 53 % | 40 % | 43 % | |
49 % | 31 % | 43 % | 51 % | 0 | 0 | 41 % | 50 % | 50 % | 46 % | 54 % | 50 % | 50 % | 49 % | 48 % | 44 % | 25 % | 46 % | 44 % | 52 % | 53 % | 50 % | 58 % | ||
51 % | 29 % | 44 % | 48 % | 52 % | 50 % | 50 % | 47 % | 51 % | 50 % | 46 % | 49 % | 50 % | 51 % | 47 % | 0 | 44 % | 17 % | 0 | 0 | 47 % | 50 % | 53 % | 62 % | |
51 % | 29 % | 44 % | 48 % | 51 % | 50 % | 50 % | 47 % | 51 % | 50 % | 46 % | 49 % | 50 % | 51 % | 47 % | 0 | 44 % | 17 % | 0 | 0 | 47 % | 50 % | 53 % | 62 % | |
50 % | 29 % | 44 % | 48 % | 51 % | 50 % | 50 % | 47 % | 51 % | 50 % | 46 % | 49 % | 50 % | 51 % | 47 % | 0 | 44 % | 17 % | 0 | 0 | 50 % | 44 % | 55 % | 62 % | |
50 % | 28 % | 44 % | 48 % | 49 % | 37 % | 50 % | 47 % | 51 % | 50 % | 47 % | 49 % | 50 % | 51 % | 47 % | 52 % | 44 % | 29 % | 46 % | 44 % | 60 % | 46 % | 47 % | 62 % | |
50 % | 28 % | 44 % | 48 % | 49 % | 37 % | 50 % | 47 % | 51 % | 50 % | 47 % | 49 % | 50 % | 51 % | 47 % | 0 | 44 % | 17 % | 0 | 0 | 60 % | 46 % | 47 % | 62 % | |
49 % | 27 % | 44 % | 48 % | 49 % | 37 % | 50 % | 47 % | 51 % | 50 % | 47 % | 49 % | 50 % | 51 % | 47 % | 0 | 44 % | 17 % | 0 | 0 | 50 % | 42 % | 51 % | 62 % | |
0 | 26 % | 44 % | 48 % | 52 % | 50 % | 50 % | 47 % | 45 % | 50 % | 45 % | 49 % | 50 % | 51 % | 0 | 0 | 0 | 17 % | 0 | 2 % | 0 | 0 | 32 % | 62 % | |
22 | 26 % | 44 % | 48 % | 52 % | 50 % | 50 % | 47 % | 45 % | 50 % | 45 % | 49 % | 50 % | 51 % | 0 | 0 | 0 | 17 % | 0 | 2 % | 0 | 0 | 0 | 62 % | |
0 | 0 | 44 % | 48 % | 66 % | 47 % | 45 % | 50 % | 45 % | 49 % | 50 % | 51 % | 0 | 0 | 0 | 17 % | 0 | 0 | 0 | 0 | 0 | 62 % | |||
0 | 0 | 44 % | 48 % | 52 % | 50 % | 50 % | 47 % | 45 % | 50 % | 45 % | 49 % | 50 % | 51 % | 0 | 0 | 0 | 17 % | 0 | 0 | 0 | 0 | 0 | 62 % | |
0 | 0 | 44 % | 48 % | 51 % | 50 % | 50 % | 47 % | 45 % | 50 % | 45 % | 49 % | 50 % | 51 % | 0 | 0 | 0 | 17 % | 0 | 0 | 0 | 0 | 0 | 62 % |
Notes:
With gcc 3.4 under Linux/x86, the -ffloat-store option is necessary, since the results of some functions of the mathematical library are and remain in extended precision after an assignment. This does not conform to the ISO/IEC 9899:1999 standard (C language); it is a bug in gcc.
The time to perform the tests on the worst cases is given for some platforms. It is high for implementations that provide correct rounding, but you have to remember that in practice, the probability to encounter such worst cases is very low.
Distribution:
Test programs for the native C functions and the GNU MPFR library. These programs take a list of tests (generally corresponding to cases that are hard to round correctly) in input, such as those given below.
Worst cases used for the tests above (775 KB). Last update on 2020-11-27, with the addition of 4 functions.
Note
Some listed worst cases
are not actually true worst cases. This comes from an old version of my filtering script: any worst case of y = f(x), where x is a value with a 54-bit precision (i.e., a machine number or the midpoint of two consecutive machine numbers) and y is very close to a machine number, was systematically generating a worst case for the inverse function f−1, though if the logarithmic derivative of f is very large, this is not necessarily a true worst case for the inverse function. I corrected the script in 2007, but I did not modify the base of values in this file, because all the machines listed in the above tables must be tested on the same values (I no longer had some machines to rerun the tests on a new base of values); the only changes I did in this file was the addition of new functions.
Directory containing additional worst cases. These are not all the hard-to-round cases I have found, but there are at least the most important ones. The subnormal numbers have been ignored (these are particular cases anyway), as if the output had an unbounded exponent range.
My publications:
Vincent Lefèvre, Jean-Michel Muller and Arnaud Tisserand. Towards Correctly Rounded Transcendentals, Proceedings of the 13th IEEE Symposium on Computer Arithmetic (ARITH-13), 1997. [PDF]
Vincent Lefèvre, Jean-Michel Muller and Arnaud Tisserand. Toward Correctly Rounded Transcendentals, IEEE Transactions on Computers, November 1998. [PDF]
Vincent Lefèvre. An Algorithm that Computes a Lower Bound on the Distance Between a Segment and ℤ², Developments in Reliable Computing, 1999.
Vincent Lefèvre. Moyens arithmétiques pour un calcul fiable, PhD thesis, École Normale Supérieure de Lyon, January 2000.
Vincent Lefèvre and Jean-Michel Muller. Worst Cases for Correct Rounding of the Elementary Functions in Double Precision, Proceedings of the 15th IEEE Symposium on Computer Arithmetic (ARITH-15), 2001. HAL-Inria / HAL / [PDF]
Vincent Lefèvre. New Results on the Distance Between a Segment and ℤ². Application to the Exact Rounding, Proceedings of the 17th IEEE Symposium on Computer Arithmetic (ARITH-17), 2005. HAL-Inria / HAL / [PDF]
Jean-Michel Muller, Nicolas Brisebarre, Florent de Dinechin, Claude-Pierre Jeannerod, Vincent Lefèvre, Guillaume Melquiond, Nathalie Revol, Damien Stehlé and Serge Torres. Handbook of Floating-Point Arithmetic, Birkhäuser Boston, first edition, 2010.
Jean-Michel Muller, Nicolas Brunie, Florent de Dinechin, Claude-Pierre Jeannerod, Mioara Joldes, Vincent Lefèvre, Guillaume Melquiond, Nathalie Revol and Serge Torres. Handbook of Floating-Point Arithmetic, Birkhäuser, Cham, second edition, 2018.
The search for worst cases for the tests above (except precomputations and postcomputations) required 49130 hours of computation on a cluster of the Centre Charles Hermite (8 biprocessor machines), 42129 hours on machines of the Laboratoire de l'Informatique du Parallélisme (ENS de Lyon, France), 9333 hours on machines of the MEDICIS computation center, and 5767 hours on machines of the Loria, in the 2000s.
This page deals with correct rounding only. For error analysis of the mathematical functions, you can look at Gaston H. Gonnet's page or at MPCHECK (by Paul Zimmermann and Nathalie Revol).