4.8.3Numerical Methods

Machine epsilon — what it means in practice

1,791 words8 min readdifficulty · medium1 backlinks

WHY does machine epsilon exist?


WHAT is a floating-point number?


HOW do we derive εmach=2t\varepsilon_{\text{mach}} = 2^{-t}?

Figure — Machine epsilon — what it means in practice

Worked examples


Forecast-then-Verify

Verify: (1) 2231.19×1072^{-23}\approx1.19\times10^{-7}. (2) Near 11; near 10002101000\approx2^{10} the gap is 210εmach2^{10}\varepsilon_{\text{mach}} — gaps grow with magnitude. (3) No — that's underflow/denormals, a separate limit (smallest normalized 2.2×10308\approx2.2\times10^{-308}, smallest subnormal 5×10324\approx5\times10^{-324}).


Flashcards

What is machine epsilon?
The gap between 1.01.0 and the next representable float; εmach=2t\varepsilon_{\text{mach}}=2^{-t}, the relative precision of the number system.
Value of εmach\varepsilon_{\text{mach}} for IEEE double precision?
2522.22×10162^{-52}\approx 2.22\times10^{-16} (t=52t=52 mantissa bits).
Why does εmach=2t\varepsilon_{\text{mach}}=2^{-t}?
Mantissa has tt fractional bits; smallest increment above 11 is flipping the last bit = 2t2^{-t}.
Difference between εmach\varepsilon_{\text{mach}} and the smallest positive float?
Epsilon = relative precision near 1 (~101610^{-16}); smallest positive float = underflow limit (smallest normalized ~2.2×103082.2\times10^{-308}, smallest subnormal ~5×103245\times10^{-324}). Different concepts.
What is unit roundoff uu?
Max relative rounding error =12εmach=2t1=\tfrac12\varepsilon_{\text{mach}}=2^{-t-1}, since rounding lands within half a gap.
Why is 0.1+0.2 != 0.3?
0.1, 0.2, 0.3 aren't exactly representable in binary; rounding leaves a residue of order εmach\varepsilon_{\text{mach}} (observed 4.44×1017\approx4.44\times10^{-17}).
Correct way to compare two floats?
xytolmax(x,y)|x-y|\le \text{tol}\cdot\max(|x|,|y|) with tol10εmach\text{tol}\sim10\,\varepsilon_{\text{mach}}, never ==.
What is catastrophic cancellation?
Subtracting two nearly-equal numbers promotes tiny rounding-error into large relative error.
Is the literal 1.0 stored exactly?
Yes — 1.0 is exactly representable; in 1cosx1-\cos x the error comes from rounding cosx\cos x, not from storing 1.01.0.
How does the gap between floats change with magnitude?
Near a number of size 2e2^e the gap is 2eεmach2^e\varepsilon_{\text{mach}} — gaps grow with magnitude.
εmach\varepsilon_{\text{mach}} for single precision (t=23t=23)?
2231.19×1072^{-23}\approx1.19\times10^{-7}.

Recall Feynman: explain to a 12-year-old

Imagine a ruler that can only show lines very close together near the number 1, but the lines get further apart as numbers get bigger. The computer can only point at a line, never between lines. Machine epsilon is the width of the smallest gap between two lines right next to the number 1. If you ask the computer to mark something thinner than that gap, it just snaps to the nearest line — that tiny snapping error is why 0.1+0.20.1+0.2 comes out a teeny bit wrong. The computer isn't dumb; it just has a smallest "pencil width", and epsilon is that width.


Connections

  • Floating-point representation (IEEE-754) — where tt, exponent, sign come from
  • Rounding error and unit roundoffu=12εmachu=\tfrac12\varepsilon_{\text{mach}}
  • Catastrophic cancellation — how epsilon-noise gets amplified
  • Condition number — output error \approx condition number ×εmach\times\,\varepsilon_{\text{mach}}
  • Numerical stability of algorithms — designing to keep error εmach\sim\varepsilon_{\text{mach}}
  • Underflow and overflow — the other limits of the number range

Concept Map

forces

leaves residue bounded by

stores number as

flip last bit gives

defines

gives eps approx 2.2e-16

halved gives

bounds relative rounding error

contrasted with

is really about

Finite memory

Rounding real numbers

Floating-point format

Mantissa with t bits

Machine epsilon = 2^-t

Gap between 1 and next float

Double precision t=52

Unit roundoff u = eps/2

Not smallest positive number

Underflow / exponent range

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, computer ke paas memory finite hoti hai, isliye woh har real number ko exactly store nahi kar sakta — usko round karna padta hai. Machine epsilon ka matlab hai: number 1.01.0 aur uske just baad wale representable number ke beech ka chhota sa gap. Double precision mein yeh gap 2522.2×10162^{-52}\approx 2.2\times10^{-16} hota hai. Yeh basically computer ki "pencil ki motai" hai — isse patli koi cheez woh mark hi nahi kar sakta, bas nearest line pe snap ho jaata hai.

Yeh kyun important hai? Kyunki har calculation mein itna chhota relative error chupa hota hai. Isiliye 0.1 + 0.2 bilkul 0.3 ke barabar nahi aata — thoda sa 0.300000000000000040.30000000000000004 aata hai, error lagbhag 4.44×10174.44\times10^{-17}. Yeh koi bug nahi, yeh epsilon ki wajah se hai. Yaad rakho: epsilon sabse chhota number nahi hai (woh underflow hai — smallest normalized ~2.2×103082.2\times10^{-308}, subnormals ke saath ~5×103245\times10^{-324} tak); epsilon to sabse chhota step hai 1 ke aas-paas.

Ek aur cheez: jaise number bada hota jaata hai, gap bhi badhta jaata hai — xx ke paas gap lagbhag xεmachx\cdot\varepsilon_{mach} hota hai. Aur jab tum do bahut-paas-paas numbers ko subtract karte ho (catastrophic cancellation), tab yeh chhota sa rounding-error bahut bada relative error ban jaata hai. Dhyaan rakho: 1cosx1-\cos x mein literal 1.01.0 to exactly stored hota hai — error to cosx\cos x ko round karne se aata hai. Isliye formulas ko smartly rewrite karna padta hai.

Practical rule: floats ko kabhi == se compare mat karo. Hamesha |x - y| <= tol * max(|x|,|y|) use karo, jahan tol epsilon ka chhota multiple ho. Bas itna samajh lo to numerical methods ki aadhi galtiyan bach jaayengi.

Test yourself — Numerical Methods

Connections