gives the difference between 1.0 and the next-nearest number representable as a machine-precision number.
$MachineEpsilon
gives the difference between 1.0 and the next-nearest number representable as a machine-precision number.
Details
- $MachineEpsilon is typically 2-n+1, where n is the number of binary bits used in the internal representation of machine‐precision floating‐point numbers.
- $MachineEpsilon measures the granularity of machine‐precision numbers.
Examples
open all close allBasic Examples (1)
$MachineEpsilonThe result of adding 1 to $MachineEpsilon is distinct from 1:
x = 1. + $MachineEpsilonx - 1.Adding a fraction of $MachineEpsilon effectively results in rounding:
y = 1. + {0.3, 0.5, 0.7}$MachineEpsilony - 1.Scope (2)
The result of subtracting $MachineEpsilon/2 from 1 is distinct from 1:
x = 1. - $MachineEpsilon / 21. - xFind machine epsilon algorithmically:
Block[{ϵ = 1.}, While[Not[PossibleZeroQ[(1. + ϵ) - 1.]], ϵ /= 2];ϵ * 2]% == $MachineEpsilonApplications (2)
Get the nearest machine number greater than another machine number:
x = RandomReal[{1, 100}]y = x * (1. + $MachineEpsilon);x - y
and
differ only in the least significant bit:
RealDigits[x, 2]RealDigits[y, 2]Horner's method for evaluating a polynomial with a running error bound:
horner[p_List, x_] := Module[{u, y, mu},
y = Last[p];
mu = Abs[y] / 2;
Do[y = x * y + c;mu = Abs[x] * mu + Abs[y], {c, Take[p, {-2, 1, -1}]}];
(* u is "unit roundoff"*)
u = $MachineEpsilon / 2;
mu = u * (2 * mu - Abs[y]);
{y, mu}]A polynomial with large coefficients:
poly = N[Expand[Product[(x - i), {i, 20}]]]Evaluate at x=10; the error is large, but within the bound:
horner[CoefficientList[poly, x], 10.]Properties & Relations (3)
$MachineEpsilon is a power of 2:
Log[2., $MachineEpsilon]$MachineEpsilon is twice 10-MachinePrecision:
$MachineEpsilon == 2 / 10 ^ MachinePrecisionThis is effectively
where
is the number of bits of machine precision:
b = MachinePrecision * Log[2., 10.]2 ^ (1 - b) == $MachineEpsilon1 and 1+$MachineEpsilon differ only in the least significant bit:
RealDigits[1., 2]RealDigits[1. + $MachineEpsilon, 2]Tech Notes
Related Guides
History
Introduced in 1991 (2.0)
Text
Wolfram Research (1991), $MachineEpsilon, Wolfram Language function, https://reference.wolfram.com/language/ref/$MachineEpsilon.html.
CMS
Wolfram Language. 1991. "$MachineEpsilon." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/$MachineEpsilon.html.
APA
Wolfram Language. (1991). $MachineEpsilon. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/$MachineEpsilon.html
BibTeX
@misc{reference.wolfram_2026_$machineepsilon, author="Wolfram Research", title="{$MachineEpsilon}", year="1991", howpublished="\url{https://reference.wolfram.com/language/ref/$MachineEpsilon.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_$machineepsilon, organization={Wolfram Research}, title={$MachineEpsilon}, year={1991}, url={https://reference.wolfram.com/language/ref/$MachineEpsilon.html}, note=[Accessed: 15-June-2026]}