Do, Undo, Repeat

Four programs, each run and then undone, ten times in a row. On the left of each card is the usual arithmetic, which rounds a little at every step. On the right is a version that cannot drift. The thumbnails record where each cycle came back to.

cycle 1 of 10
Chaos · deeper each cycle

Scramble, then unscramble

The kicked rotor scrambles the picture and runs back, 12 steps each way in cycle 1, 24 in cycle 2, up to 120. Floating point starts losing the chaotic sea at about 50 steps. The lattice moves whole cells and runs the verified machine code's arithmetic.

Floating point
Exact lattice
cycle 1 · 12 stepsrecord of each returncycle 10 · 120 steps
Geometry · you would not expect this one

Rotate 30°, rotate back

A photo editor rotates by resampling each pixel from its neighbours. Undoing it resamples again, so every cycle blurs the picture, and the corners that left the canvas never return. The exact version is three shears of whole cells, the same arithmetic the verified code does.

Bilinear resampling
Three exact shears
cycle 1record of each returncycle 10
Real case · Vancouver, 1982–83

The index that lost half its value

The Vancouver Stock Exchange started a new index at 1,000 in January 1982 and updated it about 3,000 times a day. Each update truncated it to three decimals, which always rounds down. After 22 months it read 524.811; recomputed properly, it was 1,098.892. Each cycle here is 2.2 months of a miniature market calibrated to those two numbers.

Truncated each update1000.000
Rounded to nearest1000.000
Recorded values from the Wall Street Journal (8 Nov 1983) and Toronto Star (29 Nov 1983), via Wikipedia. Miniature: 2,280 random updates per trading day for 478 trading days.
Real case · Dhahran, 25 February 1991

The clock that drifted a third of a second

A Patriot battery counted time in tenths of a second, then multiplied by 1/10 held in a 24-bit register. 1/10 has no exact binary form, so each tick lost 0.000000095 s. After 100 hours of continuous running the tracking gate had moved 687 m. It did not track the incoming Scud, and 28 soldiers were killed. Each cycle here is 10 hours of uptime.

Clock, integer ticks ÷ 100.0000 s
Clock, ticks × chopped 1/100.0000 s
HoursTime error (s)Gate shift (m)Target
Arithmetic and gate shifts reproduce GAO report IMTEC-92-26 (1992), Appendix II. The gate's width is drawn schematically: GAO notes the target fell outside it after about 20 hours.