Verify: (1) 2−23≈1.19×10−7. (2) Near 1; near 1000≈210 the gap is 210εmach — gaps grow with magnitude. (3) No — that's underflow/denormals, a separate limit (smallest normalized ≈2.2×10−308, smallest subnormal ≈5×10−324).
Max relative rounding error =21ε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 (observed ≈4.44×10−17).
Correct way to compare two floats?
∣x−y∣≤tol⋅max(∣x∣,∣y∣) with tol∼10ε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 1−cosx the error comes from rounding cosx, not from storing 1.0.
How does the gap between floats change with magnitude?
Near a number of size 2e the gap is 2eεmach — gaps grow with magnitude.
εmach for single precision (t=23)?
2−23≈1.19×10−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.2 comes out a teeny bit wrong. The computer isn't dumb; it just has a smallest "pencil width", and epsilon is that width.
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.0 aur uske just baad wale representable number ke beech ka chhota sa gap. Double precision mein yeh gap 2−52≈2.2×10−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.30000000000000004 aata hai, error lagbhag 4.44×10−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×10−308, subnormals ke saath ~5×10−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 — x ke paas gap lagbhag x⋅ε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: 1−cosx mein literal 1.0 to exactly stored hota hai — error to cosx 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.