MakarovSuites
English
EnglishDeutschРусскийУкраїнськаFrançaisEspañolItalianoPolski
Contact & licences

Math

A code that repairs itself

Sixteen bits in a square, eleven of them a message: click one and the four check lamps spell out its address, and the block puts itself right. Two errors are caught but not repairable; three, and the block lies with confidence. Every claim is exhaustive - all 32 768 single errors located, all 245 760 double errors caught, every triple mis-corrected.

A code that repairs itself — Actual application image
Actual application image

What happens

Sixteen bits laid out four by four. Eleven carry a message; four are parity checks sitting at the powers of two - 1, 2, 4, 8 - and a fifth at position 0 checks the whole square. Each check watches exactly half the block: check 1 watches every odd index, check 2 watches indices 2, 3, 6, 7, 10, 11, 14, 15, and so on. Because every index belongs to a different combination of checks, the four answers read together are not an alarm but an ADDRESS: exclusive-or the indices of every set bit and the result is the number written under the wrong tile. Click any tile to flip it and watch the lamps spell it out. Flip a second and the block still knows something is wrong - the sixteenth bit, the one checking the whole square, is what separates "correct one error" from "correct one and know when there are two". Flip a third and the code lies: it names a tile with complete confidence and hands back the wrong message. Distance four buys one repair and two detections, and nothing beyond. Without that sixteenth bit the code is PERFECT in the technical sense: 2048 codewords, each with fifteen neighbours one flip away, and 2048 x 16 = 32 768 = 2^15 exactly - the spheres of radius one tile the space with nothing left over. This is the arithmetic inside ECC memory, inside every QR code, and on the surface of every optical disc; it is why a scratched CD still plays.

Equations used in the module
Equations
syndrome:  s = XOR of the indices of every set bit;  s = 0 means the four checks agree, and s ≠ 0 IS the address of the wrong bit
checks:  check p watches every index i with (i AND p) ≠ 0;  p = 1, 2, 4, 8, and position 0 checks the whole square
verdict:  s = 0 and parity even → whole;  parity odd → one error at s (s = 0 means bit 0 itself);  s ≠ 0 and parity even → two errors, detected and not repairable
perfect code:  Hamming(15,11) has 2^11 = 2048 codewords, each with 15 neighbours one flip away;  2048 × 16 = 32 768 = 2^15 exactly - the spheres of radius one tile the space with nothing left over
distance:  d = 3 for Hamming(15,11), d = 4 with the whole-square bit;  correcting t errors needs d ≥ 2t + 1, detecting t needs d ≥ t + 1
exhaustive:  32 768 single-bit cases, 0 mislocated;  245 760 double-bit cases, 0 missed and 0 mis-corrected;  35 840 triple-bit cases, all 35 840 "corrected" wrongly
rate:  11 message bits per 16 sent = 68.75 %;  Hamming(7,4) 57.1 %, Hamming(31,26) 83.9 %, Hamming(63,57) 90.5 % - longer blocks are cheaper insurance and lose more to a second error

Related experiments

Back to catalogue
Basins of Newton's method — Actual application image

Math

Basins of Newton's method

Colour every starting point by the root Newton's method reaches: with two roots the boundary is a straight line, as Cayley proved in 1879, and with three it is a fractal that all three basins share. Drag a root and watch the areas move - a root pulled outward takes LESS of the window, not more.

Random walks and PageRank — Actual application image

Math

Random walks and PageRank

Follow probability mass through a directed graph and compare power iteration with a crowd of random walkers. Teleportation can make PageRank converge to a unique distribution. Compare a periodic cycle with a graph whose unpatched dangling nodes leak mass.

The cusp catastrophe — Actual application image

Math

The cusp catastrophe

Drag one knob and the state slides until its branch runs out, then snaps - and dragging back does not undo it. Turn the second knob above the cusp and the snap vanishes entirely: the hysteresis loop is not small there, it is exactly zero. Loop width 4·(−a/3)^(3/2), jump height 3·√(−a/3), both checkable against the picture.