Floating-point error mitigation is the minimization of errors caused by the fact that real numbers cannot, in general, be accurately represented in a fixed space. By definition,floating-point error cannot be eliminated, and, at best, can only be managed.
Huberto M. Sierra noted in his 1956 patent "Floating Decimal Point Arithmetic Control Means for Calculator":[1]
Thus under some conditions, the major portion of the significant data digits may lie beyond the capacity of the registers. Therefore, the result obtained may have little meaning if not totally erroneous.
TheZ1, developed byKonrad Zuse in 1936, was the first computer withfloating-point arithmetic and was thus susceptible to floating-point error. Early computers, however, with operation times measured in milliseconds, could not solve large, complex problems[2] and thus were seldom plagued with floating-point error. Today, however, withsupercomputer system performance measured inpetaflops, floating-point error is a major concern for computational problem solvers.
The following sections describe the strengths and weaknesses of various means of mitigating floating-point error.
Though not the primary focus ofnumerical analysis,[3][4]: 5 numerical error analysis exists for the analysis and minimization of floating-point rounding error.
Error analysis byMonte Carlo arithmetic is accomplished by repeatedly injecting small errors into an algorithm's data values and determining the relative effect on the results.
Extension of precision is using of larger representations of real values than the one initially considered. TheIEEE 754 standard defines precision as the number of digits available to represent real numbers. A programming language can includesingle precision (32 bits),double precision (64 bits), andquadruple precision (128 bits). While extension of precision makes the effects of error less likely or less important, the true accuracy of the results is still unknown.
Variable length arithmetic represents numbers as a string of digits of a variable's length limited only by the memory available. Variable-length arithmetic operations are considerably slower than fixed-length format floating-point instructions. When high performance is not a requirement, but high precision is, variable length arithmetic can prove useful, though the actual accuracy of the result may not be known.
The floating-point algorithm known asTwoSum[5] or2Sum, due to Knuth and Møller, and its simpler, but restricted versionFastTwoSum orFast2Sum (3 operations instead of 6), allow one to get the (exact) error term of a floating-point addition rounded to nearest. One can also obtain the (exact) error term of a floating-point multiplication rounded to nearest in 2 operations with afused multiply–add (FMA), or 17 operations if the FMA is not available (with an algorithm due to Dekker). These error terms can be used in algorithms in order to improve the accuracy of the final result, e.g. withfloating-point expansions orcompensated algorithms.
Operations giving the result of a floating-point addition or multiplication rounded to nearest with its error term (but slightly differing from algorithms mentioned above) have been standardized and recommended in the IEEE 754-2019 standard.
Changing theradix, in particular from binary to decimal, can help to reduce the error and better control the rounding in some applications, such asfinancial applications.
Interval arithmetic is a mathematical technique used to put bounds onrounding errors andmeasurement errors inmathematical computation. Values are intervals, which can be represented in various ways, such as:[6]
"Instead of using a single floating-point number as approximation for the value of a real variable in the mathematical model under investigation, interval arithmetic acknowledges limited precision by associating with the variable a set of reals as possible values. For ease of storage and computation, these sets are restricted to intervals."[7]
The evaluation of interval arithmetic expression may provide a large range of values,[7] and may seriously overestimate the true error boundaries.[8]: 8
Unums ("Universal Numbers") are an extension of variable length arithmetic proposed byJohn Gustafson.[9] Unums have variable length fields for the exponent andsignificand lengths and error information is carried in a single bit, the ubit, representing possible error in the least significant bit of the significand (ULP).[9]: 4
The efficacy of unums is questioned byWilliam Kahan.[8]
Bounded floating point is a method proposed and patented by Alan Jorgensen.[10] The data structure includes the standardIEEE 754 data structure and interpretation, as well as information about the error between the true real value represented and the value stored by the floating point representation.[11]
Bounded floating point has been criticized as being derivative of Gustafson's work on unums and interval arithmetic.[10][12]