({{, (RefLink[$MachineEpsilon, paclet:ref/$MachineEpsilon])
gives the difference between 1.0 and the next-nearest number representable as a machine-precision number. }})

OpenersNotesSection(Spacer1)Details

(RefLink[$MachineEpsilon, paclet:ref/$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.

(RefLink[$MachineEpsilon, paclet:ref/$MachineEpsilon]) measures the granularity of machine-precision numbers.

OpenersPrimaryExamplesSection(Spacer1)Examples  (9)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

$MachineEpsilon

The result of adding 1 to (RefLink[$MachineEpsilon, paclet:ref/$MachineEpsilon]) is distinct from 1:

x=1.+$MachineEpsilon

x-1.

Adding a fraction of (RefLink[$MachineEpsilon, paclet:ref/$MachineEpsilon]) effectively results in rounding:

y=1.+{0.3,0.5,0.7}$MachineEpsilon

y-1.

OpenersExampleSection1(Spacer1)Scope  (2)

The result of subtracting $MachineEpsilon/2 from 1 is distinct from 1:

x=1.-$MachineEpsilon/2

1.-x

Find machine epsilon algorithmically:

Block[{ϵ=1.},While[Not[PossibleZeroQ[(1.+ϵ) - 1.]],ϵ/=2];ϵ*2]

%==$MachineEpsilon

OpenersExampleSection2(Spacer1)Applications  (2)

Get the nearest machine number greater than another machine number:

x=RandomReal[{1,100}]

y=x*(1.+$MachineEpsilon);

x and y are distinct:

x-y

x and y 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.]

OpenersExampleSection3(Spacer1)Properties & Relations  (3)

(RefLink[$MachineEpsilon, paclet:ref/$MachineEpsilon]) is a power of 2:

Log[2.,$MachineEpsilon]

(RefLink[$MachineEpsilon, paclet:ref/$MachineEpsilon]) is twice (10^(-(RefLink[MachinePrecision, paclet:ref/MachinePrecision]))):

$MachineEpsilon==2/10^MachinePrecision

This is effectively (2^(1-b)) where b is the number of bits of machine precision:

b=MachinePrecision*Log[2.,10.]

2^(1-b)==$MachineEpsilon

1 and 1+(RefLink[$MachineEpsilon, paclet:ref/$MachineEpsilon]) differ only in the least significant bit:

RealDigits[1.,2]

RealDigits[1.+$MachineEpsilon,2]

OpenersExampleSection4(Spacer1)Neat Examples  (1)

The resolution of machine numbers is twice as fine just below 1 versus just above 1:

Plot[(1+x)-1,{x,-2$MachineEpsilon,2 $MachineEpsilon},PlotRange->All]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[$MachinePrecision, paclet:ref/$MachinePrecision])  ▪  (RefLink[$MinMachineNumber, paclet:ref/$MinMachineNumber])  ▪  (RefLink[$MaxMachineNumber, paclet:ref/$MaxMachineNumber])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Machine-Precision Numbers, paclet:tutorial/MachinePrecisionNumbers])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[System Information, paclet:guide/SystemInformation])}, {▪(RefLinkPlain[Precision & Accuracy Control, paclet:guide/PrecisionAndAccuracyControl])}, {▪(RefLinkPlain[Representation of Numbers, paclet:guide/RepresentationOfNumbers])}})}})