Lab · c06.s02.L1
Cancellation demo
Cancellation does not create error: it exposes the rounding the two operands already carried, in proportion to the cancellation ratio.
Question: Why does subtracting two correct numbers give a wrong answer?
Frame 1 of 15: 0 digits, binary64At 0 shared digits the operands are a = 1.5 and b = 0.5. The true difference is 1.0 and the computed difference is 1.0, so the relative error is exactly 0.0; it is drawn at the 1e-18 floor. Nothing cancels, and the cancellation ratio is 2.0.
0 digits, binary64. At 0 shared digits the operands are a = 1.5 and b = 0.5. The true difference is 1.0 and the computed difference is 1.0, so the relative error is exactly 0.0; it is drawn at the 1e-18 floor. Nothing cancels, and the cancellation ratio is 2.0.
Keyboard: Space plays or pauses, Left and Right step, Home goes to the first frame, End goes to the last frame.
Text description of this lab
Two numbers straddling 1 share 0 to 18 leading digits. A log-scale chart plots the relative error of their difference: a russet curve with round markers climbs, a gold dashed line shows one rounding times the cancellation ratio, and a dotted rule marks 1, where no digits are correct. At 16 shared digits both store as 1.0, the difference is 0.0, and the relative error is 1.0: the subtraction exposed rounding the operands carried.
Return to the section that hosts this lab
Caption status: re-simulated. Every lab declares one of published, re-simulated, schematic, synthetic or interpolated.