Machine epsilon

Machine epsilon

In floating point arithmetic, the machine epsilon (also called macheps, machine precision or unit roundoff) is, for a particular floating point unit, the difference between 1 and the smallest exactly representable number greater than one. It gives an upper bound on the relative error due to rounding of floating point numbers [*cite journal
author = David Goldberg
title = What Every Computer Scientist Should Know About Floating-Point Arithmetic
journal = ACM Computing Surveys (CSUR)
year = 1991
month = March
volume = 23
issue = 1
pages = 5–48
doi = 10.1145/103162.103163
url = http://www.validlab.com/goldberg/paper.pdf
accessdate = 2008-04-28
quote =
] .

Example

An IEEE 754 single precision floating point number has 24 bits of mantissa, including the leading unit digit. The number 1 is represented with an unbiased exponent of 0 and a mantissa of 1.000000000000000000000002 in binary. The next largest representable number has an exponent of 0 and a mantissa of 1.000000000000000000000012. The difference between these numbers is 0.000000000000000000000012, or 2−23. This is the machine epsilon of a floating point unit which uses IEEE single-precision floating point arithmetic. In general, for a floating point type with a base "b" and a mantissa of "p" digits, the epsilon is εmach = "b"1-"p".

Other definitions

The machine epsilon is sometimes defined as the smallest positive number which, when added to 1, yields a result other than one. Unlike the definition above, this value depends on the rounding mode. For IEEE single precision in the most common rounding mode (round to even), this value is 2−24 + 2−47, or slightly more than half the value by the definition above. For rounding toward +∞ the value is the smallest representable positive number (2−149, a denormal), while for rounding toward -∞ or toward zero it coincides with the earlier definition.

Some documents mistakenly use this definition when the other is intended. For example, both the GNU libc manual [ [http://www.gnu.org/software/libc/manual/html_node/Floating-Point-Parameters.html GNU libc manual, section A.5.3.2] , dated August 5, 2007, retrieved September 28, 2007. ] and Microsoft Visual C++ documentation [ [http://msdn2.microsoft.com/en-us/library/k15zsh48(VS.80).aspx Run-Time Library Reference: Data Type Constants] , retrieved September 28, 2007. ] define the constant FLT_EPSILON in this way, in conflict with the ISO C standard [WG14 N1124, section 5.2.4.2.2, paragraph 11.] , which mandates the definition at the head of this article, and with their own implementations, which follow the standard.

How to determine the macheps

Note that results depend on the particular floating-point format used, such as float, double, long double, or similar as supported by the programming language, the compiler, and the runtime library for the actual platform.

Some formats supported by the processor might be not supported by the chosen compiler and operating system. Other formats might be emulated by the runtime library, including arbitrary-precision arithmetic available in some languages and libraries.

In a strict sense the term "machine epsilon" means the 1+eps accuracy directly supported by the processor (or coprocessor), not some 1+eps accuracy supported by a specific compiler for a specific operating system, unless it's known to use the best format.

A trivial example is the machine epsilon for integer arithmetic on processors without floating point formats; it is 1, because 1+1=2 is the smallest integer greater than 1.

The following C program does not actually determine the machine epsilon; rather, it determines a number within a factor of two (one order of magnitude) of the true machine epsilon, using a linear search.

#include int main( int argc, char **argv ) { float machEps = 1.0f; printf( "current Epsilon, 1 + current Epsilon " ); do { printf( "%G %.20f ", machEps, (1.0f + machEps) ); machEps /= 2.0f; // If next epsilon yields 1, then break, because current // epsilon is the machine epsilon. } while ((float)(1.0 + (machEps/2.0)) != 1.0); printf( " Calculated Machine epsilon: %G ", machEps ); return 0; } Abridged Output

$ gcc machine_epsilon.c; ./a.out current Epsilon, 1 + current Epsilon 1 2.00000000000000000000 0.5 1.50000000000000000000 ... 0.000244141 1.00024414062500000000 0.00012207 1.00012207031250000000 6.10352E-05 1.00006103515625000000 3.05176E-05 1.00003051757812500000 1.52588E-05 1.00001525878906250000 7.62939E-06 1.00000762939453125000 3.8147E-06 1.00000381469726562500 1.90735E-06 1.00000190734863281250 9.53674E-07 1.00000095367431640625 4.76837E-07 1.00000047683715820312 2.38419E-07 1.00000023841857910156 Calculated Machine epsilon: 1.19209E-07

A similar, Java method:

private void calculateMachineEpsilonFloat() { float machEps = 1.0f; do { machEps /= 2.0f; } while ((float)(1.0 + (machEps/2.0)) != 1.0); System.out.println( "Calculated Machine epsilon: " + machEps ); }

References

ee also

* Floating point - general discussion of accuracy issues in floating point arithmetic

External links

* [http://orion.math.iastate.edu/burkardt/c_src/machar/machar.html MACHAR] , a routine (in C and Fortran) to "dynamically compute machine constants" (ACM algorithm 722)


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • Epsilon — (uppercase Ε, lowercase ε; el. Έψιλον) is the fifth letter of the Greek alphabet, corresponding phonetically to a close mid front unrounded vowel /e/. In the system of Greek numerals it has a value of 5. It was derived from the Phoenician letter… …   Wikipedia

  • Epsilon III — Infobox fictional planet name=Epsilon III imagesize=250px caption=Babylon 5 orbitting Epsilon III universe= Babylon 5 locations= races=Varn Draal Zathras people= creator=J. Michael Straczynski genre=Sci fi Epsilon III is a planet in the science… …   Wikipedia

  • Nondeterministic finite state machine — In the theory of computation, a nondeterministic finite state machine or nondeterministic finite automaton (NFA) is a finite state machine where for each pair of state and input symbol there may be several possible next states. This distinguishes …   Wikipedia

  • Nondeterministic finite-state machine — In the theory of computation, a nondeterministic finite state machine or nondeterministic finite automaton (NFA) is a finite state machine where for each pair of state and input symbol there may be several possible next states. This distinguishes …   Wikipedia

  • Great Machine — The Great Machine is an enormous technological marvel beneath the surface of the planet Epsilon III in Babylon 5 . Although the size of the machine is not specified, it is similar in concept to the great machine of the Krell of Altair IV in… …   Wikipedia

  • Theta Nu Epsilon — Founded at Wesleyan University as a chapter of Skull and Bones. ΘΝΕ (Theta Nu Epsilon), also known widely as TNE, (or, at the University of Alabama, The Machine), Theta Nu Epsilon is primarily a sophomore class society that accepts members… …   Wikipedia

  • The Machine — otheruses4|a coalition of fraternities and sororities|other uses|Machine (disambiguation)The Machine, the former Alpha Rho chapter of Theta Nu Epsilon at the University of Alabama, is a select coalition of traditionally white fraternities and… …   Wikipedia

  • Queue machine — A queue machine or queue automaton is a finite state machine with the ability to store and retrieve data from an infinite memory queue. It is a model of computation equivalent to a Turing machine, and therefore it can process any formal language …   Wikipedia

  • Finite-state machine — State machine redirects here. For infinite state machines, see State transition system. For fault tolerance methodology, see State machine replication. SFSM redirects here. For the Italian railway company, see Circumvesuviana. A finite state… …   Wikipedia

  • Finite state machine — A finite state machine (FSM) or finite state automaton (plural: automata ) or simply a state machine, is a model of behavior composed of a finite number of states, transitions between those states, and actions. A finite state machine is an… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”