When dealing with floating-point numbers, computers cannot store exact values. They may store floating point values to many decimal places, and calculate results to many decimal places of precision, but round-off error will always be present. To ensure that results of floating-point routines are meaningful, the need exists to quantify the round-off error of such routines. To do this, we must calculate the machine epsilon of the computer on which the software is running.
Machine epsilon, epsmch, is defined as the smallest positive number such that 1.0 + epsmch is not equal to 1.0.
If you are familiar with the "C" or "C++" programming languages, epsmch is supplied in one of the C library files as a constant: DBL_EPSILON. It is accessed by including the header file float.h in the "C" or "C++" program.
(On my PC, the MSDN library outputs DBL_EPSILON as 2.2204460492503131e-16.)
The utilities on this site each calculate epsmch by brute force, rather than use a constant. This approach was taken to make the routine general enough to transport to other machines. In addition, the machine running the utilities posted on this site is not known and, even if presently known, may change in the future. Here is the code that I use to calculate Machine Epsilon:
var temp1, temp2, mchEps
temp1 = 1.0
do {
mchEps = temp1
temp1 /= 2
temp2 = 1.0 + temp1
} while (temp2 > 1.0)
Upon exiting the do-loop, mchEps should have the value of the Machine Epsilon
If you want to know the value of epsmch of the machine running the utilities on this site, click on the button below. The utility that calculates this value of epsmch is written in JavaScript, so make sure that JavaScript is enabled in your browser.
How is epsmch used?
The utilities posted on this site use epsmch in different ways. For example, the one-dimensional root-finders find roots on the order of epsmch, whereas the one-dimensional maximizers/minimizers find the desired result on the order of the square root of epsmch. Consider a specific example: the utility to solve Kepler's Equation is a one-dimensional root-finder. Its algorithm keeps seeking a root until it finds one on the order of epsmch; to try to get better resolution would not be possible on these pages.