Computation

A polynomial through the gaps

Write the message as the coefficients of a polynomial and send its values instead. Any k of them determine the polynomial, so it does not matter which ones are lost — and it does not matter how many, as long as k survive.
18 min read 7 figures The same thing twiceSmall cases lie

Worth reading first: Finding the error without reading the message.

Two points determine a line. Three determine a parabola. That fact, taken seriously and done over a finite alphabet, is a code.

A degree-2 polynomial over GF(11), and the 7 values sentA grid of the finite field with the polynomial's value at each point marked, and the transmitted symbols picked out.012345678910012345678910sentf(0) = 4f(1) = 8f(2) = 7f(3) = 1f(4) = 1f(5) = 7f(6) = 8the message 4, 1, 3 read as 3x² + 1x + 4 over GF(11), evaluated at x = 0…6all 35 ways of keeping 3 of the 7 values were interpolated and every one returned the message
Fig. 1 The message 4, 1, 3 read as the polynomial 3x² + x + 4 over the field with eleven elements, evaluated at x = 0 to 6. All 35 ways of keeping 3 of those 7 values were interpolated, and every one returned the message.

The construction

Fix a finite field — here the integers modulo 1111, which is a field because 1111 is prime, so every non-zero remainder has a reciprocal.

Take the message to be kk symbols from that field, and read them as the coefficients of a polynomial ff of degree less than kk. Choose nn distinct points of the field, with n>kn > k, and send the values

f(x1), f(x2), , f(xn).f(x_1),\ f(x_2),\ \dots,\ f(x_n).

That is the whole encoder. The figure above does it with k=3k=3, n=7n=7 and p=11p=11: the message 4,1,34, 1, 3 becomes 3x2+x+43x^2 + x + 4, and the seven values sent are 4,8,7,1,1,7,84, 8, 7, 1, 1, 7, 8.

Why any kk of them are enough

A polynomial of degree less than kk is determined by its values at any kk distinct points. There are two ways to see it and both matter.

By interpolation. Lagrange’s formula writes the polynomial down explicitly from kk points, as a sum of kk terms each of which is 11 at one point and 00 at the others. Every step is field arithmetic — subtractions and one division — so the formula works over the integers mod 1111 exactly as it does over the reals.

By counting roots. If two polynomials of degree less than kk agreed at kk points, their difference would be a polynomial of degree less than kk with kk roots, and a non-zero polynomial cannot have more roots than its degree. So the difference is zero.

The second argument is the one that generalises, and it is worth noticing that it needs the alphabet to be a field. Over the integers modulo 88 — not a field, because 22 times 44 leaves no remainder — the polynomial 2x2x has two roots, 00 and 44, and the whole argument collapses. That is the reason a finite field is required rather than merely a finite set with arithmetic on it.

Erasures, which are the easy failure

The channel model changes here, and the change is what makes the code so clean.

A flip turns a symbol into a different symbol without saying so. An erasure removes a symbol and says which one is missing — a disc sector that fails to read, a packet that never arrives, a scratch whose position is known.

Erasures are much easier, because the positions of the survivors are known and any kk of them suffice.

4 symbols lost out of 7, and the message recoveredA row of transmitted symbols with some erased, the surviving ones used to interpolate, and the erased ones filled back in.sentreceivedrebuilt444x=08?8x=1777x=21?1x=3111x=47?7x=58?8x=64 of the 7 symbols lost, 3 left, and 3 is all it takes — the message came backexactlywith one fewer survivor, 11 different messages fit the points that remain, which isevery value the missing symbol could take
Fig. 2 Four of the seven symbols lost, three left, and three is all it takes. The survivors interpolate the polynomial and the missing values are recomputed from it — exactly, because there is no approximation anywhere in the arithmetic.
4 symbols lost out of 7, and the message recoveredA row of transmitted symbols with some erased, the surviving ones used to interpolate, and the erased ones filled back in.sentreceivedrebuilt4?4x=0888x=17?7x=2111x=31?1x=4777x=58?8x=64 of the 7 symbols lost, 3 left, and 3 is all it takes — the message came backexactlywith one fewer survivor, 11 different messages fit the points that remain, which isevery value the missing symbol could take
Fig. 3 A different four lost, and the same recovery. Which symbols survive does not matter and never did — the only quantity in the argument is how many.

The two figures make the point that no single one could. It is not that this code tolerates these four erasures; it tolerates any four, and the figures show two disjoint choices working identically. The generator checks all (73)=35\binom{7}{3} = 35 ways of choosing which three survive, on every placement, and requires the recovered coefficients to be the ones sent.

Where the boundary is

One symbol fewer and everything stops, which is worth showing because a boundary that is not exhibited is a boundary the reader has to take on trust.

With only k1k-1 survivors, the number of messages consistent with them is exactly pp — one for each value the missing constraint could take. The figures compute that count directly by trying all pkp^k possible messages and keeping the ones that agree with the survivors, and the answer is 1111.

So the code is not merely good at nkn-k erasures; it is precisely at the edge. Recovery is certain up to nkn-k losses and impossible at nk+1n-k+1, with no grey region between.

Interpolation, done exactly

It is worth watching one recovery in full, because “interpolate” is a word that hides whether anything difficult is happening, and here nothing is.

Suppose the surviving points are (0,4)(0,4), (2,7)(2,7) and (4,1)(4,1), over the integers mod 1111. Lagrange’s basis polynomial for the first point is

0(x)=(x2)(x4)(02)(04)=(x2)(x4)8,\ell_0(x) = \frac{(x-2)(x-4)}{(0-2)(0-4)} = \frac{(x-2)(x-4)}{8},

and dividing by 88 mod 1111 means multiplying by the reciprocal of 88, which is 77 because 8×7=56=55+18 \times 7 = 56 = 55 + 1. So the division is a multiplication and there is no rounding anywhere.

Building all three basis polynomials, scaling each by its point’s value and adding gives 3x2+x+43x^2 + x + 4, which is the message. Every operation was an addition, a multiplication or a lookup of a reciprocal in a table of ten entries.

That exactness is the difference between this and interpolation over the real numbers, where fitting a high-degree polynomial to data is famously unstable and small changes in the values move the curve wildly. There is no stability question here because there is no notion of small. Two field elements are equal or they are not, and the recovered polynomial is right or it is not.

Distance, measured over every codeword

For flips rather than erasures the relevant quantity is the minimum distance, and it can be read off the same root-counting argument.

A non-zero message gives a non-zero polynomial of degree less than kk, which has at most k1k-1 roots, so at most k1k-1 of the nn transmitted values are zero and at least nk+1n-k+1 are not. Since the code is linear, that minimum weight is the minimum distance.

The weight of every codeword of a [6, 2] polynomial codeA bar chart of how many codewords have each number of non-zero symbols, with the lightest non-zero weight marked.011234560660how many codewords have that weightweightall 121 codewords weighed: the lightest non-zero one has 5 symbols not zero, and n − k + 1= 5so any two codewords differ in at least that many places, which is the most any code ofthis size can manage
Fig. 4 Every codeword of a [6, 2] code over GF(11) weighed — all 121 of them. Sixty have weight 5 and sixty have weight 6; the lightest non-zero one has weight 5, and n − k + 1 is 5.
The weight of every codeword of a [6, 3] polynomial codeA bar chart of how many codewords have each number of non-zero symbols, with the lightest non-zero weight marked.0112349051086144how many codewords have that weightweightall 343 codewords weighed: the lightest non-zero one has 4 symbols not zero, and n − k + 1= 4so any two codewords differ in at least that many places, which is the most any code ofthis size can manage
Fig. 5 The same census on a [6, 3] code over GF(7): 343 codewords, none of weight 1, 2 or 3, and 90 of weight 4. The lightest non-zero weight is 4, which is again n − k + 1.

The Singleton bound says no code can do better: a code of length nn with MM codewords and distance dd satisfies Mqnd+1M \le q^{\,n-d+1}, because deleting d1d-1 symbols from every codeword must still leave them all distinct, and there are only qnd+1q^{\,n-d+1} shortened words to be distinct in.

Codes meeting it are called maximum distance separable, and they are rare. These are them. The distance is nk+1n-k+1 exactly, at every length and every dimension, over any field big enough to supply nn distinct points.

The bound’s proof is worth one more look because it is a clean piece of counting of the kind this collection keeps returning to. Delete the first d1d-1 symbols from every codeword. Two codewords that agreed on everything remaining would differ in at most d1d-1 places, contradicting the minimum distance — so the shortened words are still all distinct. There are qnd+1q^{\,n-d+1} possible shortened words, so there were at most that many codewords to begin with. No construction, no algebra, and it applies to every code there is.

The arithmetic of GF(5)Addition and multiplication tables of a finite field, optionally beside the table of a ring of the same kind of size.+01234012340123412340234013401240123×01234012340000001234024130314204321the 5 elements of GF(5) — every product of two non-zero elements is non-zeroassociativity and distributivity were checked over all 125 triples
Fig. 6 The arithmetic all of this runs on: the field with five elements, its addition and multiplication tables complete, and no two non-zero entries multiplying to zero. That last property is the whole reason a polynomial cannot have extra roots.

What that costs

Nothing is free, and the cost here is the alphabet.

The construction needs nn distinct evaluation points, so nqn \le q: the codeword cannot be longer than the field. Correcting a lot of errors in a long message therefore means a large field, and a large field means symbols carrying many bits each.

In practice the field is GF(256)GF(256) and a symbol is a byte. The standard code on a compact disc is [32,28][32, 28] over that field; the one on a QR code is [255,k][255, k] with kk chosen by the error-correction level; the one on the Voyager missions after Jupiter was [255,223][255, 223], correcting sixteen bad bytes in every two hundred and fifty-five.

That byte-sized alphabet is also the answer to the burst problem of the previous rung. Eight consecutive bad bits inside one byte are one wrong symbol, not eight wrong bits, so a code that corrects sixteen symbol errors survives a scratch a hundred and twenty-eight bits long. Choosing the alphabet to match the shape of the damage is most of the engineering.

For flips the accounting differs from erasures by exactly a factor of two, and the reason is worth stating.

An erasure is a known position and an unknown value: one unknown. A flip is an unknown position and an unknown value: two unknowns. So nkn-k redundant symbols buy nkn-k erasures or (nk)/2\lfloor (n-k)/2 \rfloor flips, and a decoder can trade between them — correcting ee erasures and tt flips whenever 2t+enk2t + e \le n-k.

That relationship is why systems that can detect where the damage is do so. A disc controller knows which sector failed; a packet network knows which packet is missing. Turning a flip into an erasure by other means doubles the value of the same redundancy, and it is often much cheaper than adding redundancy.

Finding the errors, which is the hard half

Everything above about flips has assumed that a decoder exists, and constructing one is a real piece of work that this essay is not going to do. It is worth saying what shape it has, because otherwise the code looks easier than it is.

With erasures the positions are given and interpolation finishes the job. With flips the decoder must find the positions, and the obvious method — try every set of tt positions, assume those are wrong, interpolate from the rest, and see whether the result is consistent — costs (nt)\binom{n}{t} interpolations, which at n=255n=255 and t=16t=16 is a number with thirty digits.

The practical algorithms do something cleverer. They compute a small number of syndromes — exactly the idea of the previous rung, generalised to this field — and then solve for an error-locator polynomial whose roots are the bad positions. Berlekamp and Massey found how to do that solve efficiently in the 1960s, and Sugiyama and others later showed it is Euclid’s algorithm on polynomials in disguise.

The relevant point for this page is that the syndrome trick survives the change of alphabet unchanged. A linear code’s check depends on the error and not on the message, whatever the field, so the decoder can work on the damage alone. What becomes harder is only the step of turning that damage into positions.

The same picture, used to keep a secret

The construction has a second life that is worth knowing, because it is the identical mathematics read with the roles swapped.

Take a secret ss and make it the constant term of a random polynomial of degree k1k-1 over a large field. Hand out nn values of that polynomial to nn people. Then any kk of them can reconstruct the polynomial and read off ss; and any k1k-1 of them learn nothing at all, because for every candidate secret there is exactly one polynomial through their points with that constant term — the same count of pp possibilities that appeared above as a failure of decoding.

That is Shamir’s secret sharing, published in 1979, and it is the same object as the code wearing a different hat — the kind of double life this collection collects. The fact that the failure mode of the code is the security property of the scheme is not a coincidence. Both are the statement that k1k-1 points determine nothing about a degree-(k1)(k-1) polynomial’s remaining freedom.

A degree-1 polynomial over GF(7), and the 5 values sentA grid of the finite field with the polynomial's value at each point marked, and the transmitted symbols picked out.01234560123456sentf(0) = 3f(1) = 5f(2) = 0f(3) = 2f(4) = 4the message 3, 2 read as 2x + 3 over GF(7), evaluated at x = 0…4all 10 ways of keeping 2 of the 5 values were interpolated and every one returned themessage
Fig. 7 The smallest interesting case: a line over GF(7), sent as five of its points. Any two recover it; any one leaves seven lines through it, which is exactly seven possible messages and no information.

What the picture cannot show

The figures here draw the polynomial’s values as dots on a grid, and the grid is a genuine picture of the field — but it is a picture of a set, not of a line.

Over the real numbers a polynomial is a curve and interpolation is visibly a matter of a curve passing through points. Over GF(11)GF(11) there is no curve. The points do not lie on anything, there is no notion of between, and the dots in the first figure form no pattern the eye can complete. Everything that makes interpolation feel inevitable in the real case — smoothness, continuity, a Taylor series’s promise that local information determines the whole — is absent.

What survives is the algebra, and only the algebra: a system of kk linear equations in kk unknowns whose matrix is invertible because the evaluation points are distinct. The figures therefore verify by computation rather than by appearance, interpolating all thirty-five subsets rather than showing a curve and inviting the reader to believe it.

That gap is worth naming because it is the general condition of this field. A finite structure can be drawn, and the drawing is honest about what is there; what it cannot do is make the argument feel forced, because the intuitions that would do the forcing come from a continuous world this one has left.

Why this construction and not a cleverer one

There is something worth pausing on in how little the code does.

The Hamming code of the previous rungs is a design: three parity checks arranged so that their columns are the seven non-zero patterns, chosen to make the syndrome name a position. Change the arrangement and the code gets worse. It is an optimisation of a specific size.

This one is not designed at all. It is one sentence of algebra — a polynomial of low degree is determined by enough of its values — and every property follows without any choices being made. The distance is optimal at every length. The erasure tolerance is optimal at every length. The evaluation points can be any distinct elements, in any order.

That is unusual and it is why Reed–Solomon codes are everywhere. A construction with no parameters to tune has no way to be tuned badly, and a construction whose correctness is one root-counting argument has very little that can be got wrong. The engineering effort in a real deployment goes into the decoder and into the choice of field, never into the code.

The contrast with the classical constructions of the first anchor of this field is instructive. There, an operation set was fixed and the question was what could be reached. Here the reachable object was specified first — a set of nn-tuples pairwise far apart — and the arithmetic was chosen to make it exist. Both are questions about what a fixed set of rules produces; the difference is which end was pinned down.

Where this ladder ends

Four rungs: distance as a geometry, a perfect packing, a decoder that ignores the message, and a construction that meets the best possible bound at every size.

What every one of them needed was an arithmetic that closes — addition, multiplication and division on a finite set, with no exceptions and no zero divisors. That object was used freely here and never examined. The next anchor examines it: which finite sets support such an arithmetic, why the answer is the prime powers and nothing else, and why the field with four elements is not the integers modulo four.

What links here

Computed from the collection, not written here: the essays that point at this one.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A dashed tag is an object no other essay names yet.

ErasureError correcting codeFinite fieldInterpolationMinimum distancePolynomialReed solomonSingleton bound