Machine accuracy
The machine accuracy is a measure of the rounding error that occurs when calculating with floating point numbers . Other common names for the machine accuracy are rounding unit ( unit roundoff ) and Maschinenepsilon (or macheps).
description
Due to the finite mantissa in floating point representation , numbers cannot be represented as precisely as desired on a computer. It has to be rounded . Instead , the computer uses the number for the further calculation.
If the rounding takes place to the nearest normalized floating point number (commercial rounding or mathematical rounding), the following applies to the relative rounding error that occurs:
This is referred to as machine accuracy. is the basis of the floating point representation and the mantissa length. The machine accuracy indicates the maximum relative rounding error.
If the rounding is made to one of the two neighboring normalized floating point numbers (rounding down, rounding up, rounding by truncation), the following applies to the relative rounding error that occurs:
Remarks
The given estimate for the rounding error only applies to normalized floating point numbers. If one approaches the number zero, the relative rounding error can also become larger and increases to 100% (for ).
Other terms for machine accuracy are also used. These are in particular rounding unit ( unit roundoff ) and sometimes Maschinenepsilon (or macheps), wherein the term Maschinenepsilon is also used for the maximum relative distance of two adjacent normalized floating point numbers. This one has the size . This results in the estimation of the relative rounding error when rounding to an adjacent normalized floating point number: If, for example, in the worst case is slightly larger than a normalized floating point number and the next larger normalized floating point number is due to rounding up, the relative distance is too smaller than the maximum relative distance two neighboring normalized floating point numbers.
example
A number system based on base 2 with mantissa length 3 should be taken as an example. The picture shows the corresponding floating point numbers in the range 1 to 8.
The number 4.2 will be rounded to 4 in this system. The absolute rounding error is then:
The relative rounding error results from:
This is of course less than the machine accuracy for this example . The machine accuracy is therefore generally a so-called worst-case estimate .
meaning
The result of a calculation is essentially dependent on the machine accuracy. Initially, the input data cannot be represented as precisely as required. This results in an error in the result. This error is described by the condition of the problem. If you multiply the condition by the machine accuracy, you get an estimate of this error. The second source of error arises from the inaccuracy of the algorithm used. This error amplification is known as stability . The corresponding stability constant can sometimes also be specified for this. A poorly conditioned problem or a moderately stable algorithm therefore requires a high level of machine accuracy or a suitable problem reformulation or the use of a more stable algorithm.
Machine accuracy in practice
Today's computers mostly work according to IEEE 754 . The machine accuracy for the data types used is for single precision and for double precision.
Approximate calculation
In practice, the machine accuracy is determined as the smallest positive floating point number for which the condition on the machine concerned
is satisfied. Since the intermediate results of the following programs can either be exactly or no longer represented due to the use of powers of 2 or powers of 1.0 + 2, the following programs calculate the relative distance between two floating point numbers. The machine accuracy with symmetrical rounding then results from half of the result.
Approximation in Fortran
From Fortran 90, the machine accuracy can be calculated by calling the intrinsic function epsilon () . The following statements can be used for Fortran 77 and earlier (variables of the real type ):
UMACHN = 1.0
10 UMACHN = 0.5*UMACHN
IF ( 1.0 + 0.5*UMACHN .GT. 1.0 ) GOTO 10
Approximation in BASIC
10 E=1.0
20 E=0.5*E
30 IF 1.0 + 0.5*E > 1.0 THEN GOTO 20
40 PRINT "EPSILON=" E
Approximation in Java
private static float calculateMachineEpsilonFloat() {
float machEps = 1.0f;
do
machEps /= 2.0f;
while ((float) (1.0 + (machEps / 2.0)) != 1.0);
return machEps;
}
Approximation in Pascal
function machine_epsilon: double;
var one_plus_halfepsilon: double;
begin
Result := 1.0;
repeat
Result := 0.5 * Result;
{ damit das Ergebnis der Addition garantiert den richtigen Typ hat,
wird es einer Variablen zugewiesen }
one_plus_halfepsilon := 1.0 + 0.5 * Result;
until one_plus_halfepsilon <= 1.0;
end;
literature
- A. Kielbasinski, H. Schwetlick: Numerical linear algebra . German Science Publishing House, 1988
- Alfio Quarteroni, Riccardo Sacco, Fausto Saleri: Numerical Mathematics 1 . Springer-Verlag, 2002, ISBN 3-540-67878-6
Individual evidence
- ^ Gisela Engeln-Müllges , Fritz Reutter: Collection of formulas for numerical mathematics with standard FORTRAN-77 programs . 5th edition. Bibliographisches Institut, Zurich 1986, ISBN 3-411-03125-5 .