Article and note
A Series Learning through the MacWilliams IdentityPart 4 of 12
An Introduction to Krawtchouk Polynomials through the MacWilliams Identity
- Published:
- Updated:
- Reading time:
- 22 min (about 4,790 words)
Introduction
In coding theory, one of the basic theorems is the MacWilliams identity. Let be the coordinate set, let , and let be a linear code over the finite field . For its dual code
where
the weight enumerator of the dual code can be computed from the weight enumerator of as follows:
This is the MacWilliams identity.
In this series, I use proofs of the MacWilliams identity as a guide to an introduction to neighbouring areas and concepts. Accordingly, this series is aimed at readers who already know at least the following basic material:
We assume that the reader already knows, at least at a basic level, the following notions:
what a (finite) field is,
what a linear code over a finite field is,
what the Hamming weight is,
what the dual code is.
(There is no problem if you do not know a proof of the MacWilliams identity.)
In this series, I look at proof methods for the MacWilliams identity under the following five broad families.
Fourier, character, and Poisson methods.
Möbius inversion, lattice theory, and shortening/puncturing methods.
Orthogonal polynomials and association schemes.
Matroids and Tutte polynomials.
Moments and double-counting methods.
In this note, I focus on the third of these: the orthogonal-polynomial and association-scheme approach. However, this note does not yet enter the full theory of association schemes. Using character sums only as a minimal tool, we reread the MacWilliams identity as a Krawtchouk transform on weight distributions. This is an entrance to the orthogonal-polynomial and association-scheme viewpoint. The aim of this note is to use a proof of the MacWilliams identity as a guide to an introduction to Krawtchouk polynomials.
The MacWilliams identity is usually written as the polynomial identity
In this note, we look at this identity at the coefficient level. Write the weight distribution of a code as
Then the weight enumerator is
The MacWilliams identity is also a transform which computes the weight distribution vector
of the dual code from the weight distribution vector
of . The coefficients appearing in this transform are the Krawtchouk polynomials.
The route in this note is as follows.
Look at weight distributions.
Define Krawtchouk polynomials by a generating function.
Become familiar with the explicit formula and small examples.
See their meaning as character sums.
Check orthogonality and the Krawtchouk transform.
Derive the coefficient-level MacWilliams identity.
Return to the usual polynomial form.
Krawtchouk polynomials are a representative example of discrete orthogonal polynomials. In the classical world of orthogonal polynomials, Hermite polynomials, Laguerre polynomials, Jacobi polynomials, and so on are well known. These have orthogonality with respect to integrals over continuous intervals. On the other hand, Krawtchouk polynomials are orthogonal with respect to sums over the finite set . This feature, being “orthogonal polynomials on a finite set”, fits very well with the Hamming weight.
The original paper on Krawtchouk polynomials is Krawtchouk [Kra29]. For their systematic place as orthogonal polynomials, Koekoek–Lesky–Swarttouw [KLS10, Chapter 9] is a standard reference. For Krawtchouk polynomials and the MacWilliams identity in coding theory, MacWilliams–Sloane [MS77, Chapter 5] is the classical standard reference.
From weight enumerators to weight distributions
First, we reinterpret the weight enumerator as a coefficient vector. Let be a finite set and let . For a word , write its Hamming weight as
Definition 2.1.
For a linear code , define
The sequence
is called the weight distribution of .
Using this notation, the weight enumerator can be written as
The weight enumerator packages the weight distribution as a single polynomial in two variables.
In order to write the MacWilliams identity at the coefficient level, write the weight distribution of the dual code as
The aim is to express in terms of the numbers . The form will be
Here is a value of a Krawtchouk polynomial.
Thus, in the proof in this note, we view the MacWilliams identity as
a linear transform on the weight distribution vector.
The entries of the matrix describing this linear transform are the Krawtchouk polynomials.
Definition of Krawtchouk polynomials
We now define Krawtchouk polynomials. In this note, we use the normalisation adapted to the -ary Hamming space which naturally appears in coding theory. There are several conventions in the literature for the placement of indices and for normalisation, but here we use the following definition.
Definition 3.1.
Fix and . For , define the numbers by the generating function
That is, is the coefficient of when the right-hand side is expanded as a polynomial in . By the explicit formula, this value is realised by substituting into a polynomial. That polynomial is called the degree- -ary Krawtchouk polynomial .
Here the subscript means “which Krawtchouk polynomial”, while the inside the parentheses means the Hamming weight substituted into that polynomial. Thus is the value of the -th polynomial at . In coding theory, one mainly uses the values for .
With this definition, we do not first read the right-hand side with as a general variable. Instead, we first define the values for the weights . The next explicit formula shows that is genuinely a polynomial in of degree at most , and that substituting the integer satisfies 3.1. In coding theory, one mainly uses it by substituting weights .
Expanding 3.1 gives the following explicit formula.
Theorem 3.2.
For ,
holds.
Proof
First fix , and expand the right-hand side of the generating function by the binomial theorem:
Taking the coefficient of , we have , so putting gives
This is equal to the coefficient of on the left-hand side of the generating function. Replacing in the right-hand side by the variable gives the polynomial in (3.2).
Here is read as the polynomial in defined by
Similarly, is also a polynomial in . When an integer is substituted, it agrees with the usual value of the binomial coefficient. In this sense, (3.2) gives as a polynomial in .
This formula already shows a coding-theoretic meaning. Fix one word of weight . Among the coordinates, coordinates are non-zero and coordinates are zero. When considering another word of weight , one encounters choices in which of its non-zero coordinates overlap with the non-zero coordinates of the fixed word, and the remaining lie on the zero-coordinate side. Krawtchouk polynomials arise when a signed sum is inserted into this counting. The point to notice is that this is not merely a sum of cardinalities. We shall explain it later as a character sum using a non-trivial additive character : at the positions overlapping with the non-zero coordinates of the fixed word, instead of simply counting the non-zero value in ways, the oscillating sum
appears. Therefore the contribution of the overlapping coordinates is not but . Viewing this value as a function of gives , and the explicit formula expresses it as the polynomial . This signed counting leads to the later interpretation as a character sum.
First examples
To become familiar with the definition, let us compute a few low-degree polynomials. The constant term of the generating function
for weight is , so
Next, looking at the coefficient of , for weight we get
Written as a polynomial in , this is
Thus is a linear polynomial in .
In particular, in the binary case, that is, when , we have
This is a quantity which appears very often in the binary Hamming space. A word of weight has zero coordinates and non-zero coordinates. In the binary case, a non-zero coordinate contributes with sign, while a zero coordinate contributes , so the difference
appears.
Example 4.1 (The binary case with ).
Let and . The generating function is
The values for are as follows:
We shall use this table later in the example of the binary repetition code. Here, notice that after fixing , we get a function of . For instance, takes the values at .
Combinatorial meaning of Krawtchouk polynomials
Krawtchouk polynomials are not merely polynomials defined by a generating function. In the Hamming space, they appear as the following natural sums.
Here, fix one non-trivial additive character of the finite field ,
That is, holds, and is not identically . Finite fields have such additive characters. Indeed, if and is a non-zero -linear map, then
is a non-trivial additive character. Here is read through the representative . Character theory is not the main subject of this note, but in order to see how Krawtchouk polynomials arise from the Hamming space, we use just this one tool. We do not assume the general theory of characters, and prove only the properties needed below. Concretely, we use only the one-coordinate character sum proved here and the formula used later to extract the indicator function of the dual code. Thus the proof in this section is arranged so that it can be followed without systematic knowledge of character theory.
The needed property of character sums is the following single fact.
Lemma 5.1.
For ,
holds.
Proof
If , then for every , so the sum is . Suppose . Then is a bijection of , so
Put the right-hand side equal to . Since is non-trivial, there is some such that . As runs through all of , so does , hence
Since , we get .
Theorem 5.2.
Let be a word of weight . Then, for every ,
holds.
Proof
Compute the generating function obtained by collecting the left-hand side over all :
Here is when , and otherwise.
For a coordinate , if , then
On the other hand, if , then is a bijection of , and by Lemma 5.1,
Therefore
Hence
Since has weight , there are coordinates with and coordinates with . Hence the generating function above is
This is equal to the generating function of the Krawtchouk polynomials,
Comparing the coefficients of gives the claim.
This theorem expresses well the coding-theoretic meaning of Krawtchouk polynomials. is the sum of the character values over the words of weight , after fixing a word of weight . In other words, Krawtchouk polynomials are
oscillating sums obtained by viewing the weight- layer of the Hamming space from a word of weight .
Here we have explained this using character sums, but if one only looks at (3.2), it is also a sum of binomial coefficients counting the ways in which coordinates overlap. Krawtchouk polynomials as orthogonal polynomials bridge these two viewpoints.
Krawtchouk polynomials as orthogonal polynomials
We now see why Krawtchouk polynomials are called “orthogonal polynomials”. Orthogonality means, roughly, that the inner product of polynomials of different degrees is . For Krawtchouk polynomials, the inner product is defined by a sum over the finite set
For , put
This is the number of words of weight in . Indeed, there are ways to choose the coordinates which are non-zero, and each non-zero coordinate has possible values.
Definition 6.1.
For functions , define
This inner product has as weights the sizes of the weight layers of the Hamming space. Krawtchouk polynomials are orthogonal with respect to this inner product. Since the values of Krawtchouk polynomials are real, the orthogonality formula is the same whether or not one writes complex conjugation.
Theorem 6.2 (Orthogonality of Krawtchouk polynomials).
For ,
holds. Here is the Kronecker delta.
Proof
Compute the generating function in two variables:
Simplifying the expression inside the parentheses gives
Therefore
On the other hand, by the definition of , the coefficient of is the left-hand side
Comparing coefficients gives (6.1).
This theorem shows that form an orthogonal basis for the function space on the finite set . This is the important point. Krawtchouk polynomials are not merely convenient coefficients; they are the orthogonal basis naturally attached to the weight layers of the Hamming space.
The Krawtchouk transform
Using Krawtchouk polynomials, one can define a transform on vectors of length . This is the Krawtchouk transform.
Definition 7.1.
For a vector , define its Krawtchouk transform by
In matrix form, the Krawtchouk transform is the operation of multiplying by the matrix
This matrix is sometimes called the Krawtchouk matrix.
The orthogonality shown just above concerns the inner product with weights
and the sum has the form
On the other hand, the self-inverse property shown here concerns multiplying the Krawtchouk matrix itself twice, and the sum has the form
The two are closely related, but the summation index and the placement of the weights differ, so we keep them separate here. Orthogonality is a formula for the weighted inner product of the functions , while self-inverseness is a formula for the product of the Krawtchouk matrix .
The Krawtchouk transform is its own inverse, up to normalisation.
Theorem 7.2.
For every vector ,
holds. That is, applying the Krawtchouk transform twice multiplies the vector by .
Proof
It is enough to show that, for all ,
holds. For fixed , collect the left-hand side into a generating function in :
Substitute
into the generating function of the Krawtchouk polynomials:
Here
Therefore
Hence the coefficient of is when , and otherwise. This is (7.1), and the claim follows.
This self-inverse property corresponds to the symmetry of the MacWilliams identity. Indeed, taking the dual of once more gives . Also, for a linear code over a finite field,
This follows from . Thus the fact that the transform on weight distributions becomes multiplication by after applying it twice is compatible with returning to the original code after taking the dual twice.
The weight distribution of the dual code and the Krawtchouk transform
We now prove the MacWilliams identity using Krawtchouk polynomials. First we prove the coefficient-level formula.
In this section too, fix one non-trivial additive character of the finite field . We do not develop character theory itself in detail, but use only the following orthogonal-complement extraction formula.
Lemma 8.1.
For every ,
holds.
Proof
If , then for every , so each term is , and the sum is .
Suppose . Then there exists such that . Since , the map is a bijection of . Since is non-trivial, there is some such that .
Put
Since is a linear code, , and as runs through all of , also runs through all of exactly once. Therefore
Since , we have .
This lemma lets us convert sums over into sums over . We then substitute the Krawtchouk-polynomial sum (5.1).
Theorem 8.2 (Coefficient-level MacWilliams identity).
Let be a linear code. Put and . Then, for every ,
holds.
Proof
Writing the number of words of weight in the dual code using the indicator function, we have
Substituting Lemma 8.1, we get
By Theorem 5.2, the inner sum is equal to
Therefore
Since there are codewords of weight , this becomes
This theorem is the coefficient version of the MacWilliams identity through Krawtchouk polynomials. In other words, the weight distribution of the dual code is the Krawtchouk transform of the weight distribution of the original code, divided by :
Returning to the polynomial form of the MacWilliams identity
From the coefficient-level formula, we derive the usual polynomial form of the MacWilliams identity.
Theorem 9.1 (MacWilliams identity).
Let be a linear code. Then
holds.
Proof
Put and . By the coefficient-level formula (8.2),
Now use the generating function of the Krawtchouk polynomials. The expression here is a formal calculation, and ultimately means that both sides agree as polynomials in .
Therefore
This proves the MacWilliams identity.
In this proof, the variable substitution in the MacWilliams identity,
appeared from the generating function of the Krawtchouk polynomials. Thus the MacWilliams identity can be viewed as
the Krawtchouk transform repackaged by the generating function called the weight enumerator.
A small example: the binary repetition code of length
Let us check the coefficient-level formula in a small example. Consider the repetition code over ,
Its weight distribution is
The dual code is
namely the set of all words of even weight. Therefore
and its weight distribution is
We check that this comes from the Krawtchouk transform.
By Example 4.1, the Krawtchouk table for and is
The coefficient-level MacWilliams identity says
Here , and , , so
From the table,
Therefore
which indeed agrees with the weight distribution of .
In polynomial form,
and the right-hand side of the MacWilliams identity is
This agrees with
In this example, multiplying each row of the Krawtchouk table by the weight distribution gives the -th coefficient of the weight distribution of the dual code.
What Krawtchouk polynomials were doing in this proof
Let us organise the roles played by Krawtchouk polynomials in the proof.
First, Krawtchouk polynomials were the transform coefficients for weight distributions. Writing the weight distribution of as and that of as , we had
This is the MacWilliams identity viewed at the coefficient level.
Second, Krawtchouk polynomials were oscillating sums over weight layers of the Hamming space. After fixing a word of weight , we had
Thus is the sum obtained by viewing the layer of weight from a word of weight .
Third, Krawtchouk polynomials formed an orthogonal basis. On the finite set , with weights
the polynomials are mutually orthogonal. This shows that Krawtchouk polynomials are not merely computational coefficients, but orthogonal polynomials attached to the distance structure of the Hamming space.
Fourth, the generating function produced the MacWilliams variable substitution. Formally substitute into
The here is a formal substitution, and the final result is an equality of polynomials in :
This is the variable substitution in the polynomial form of the MacWilliams identity.
Thus, in the proof in this note, Krawtchouk polynomials played four roles:
transform coefficients for computing the weight distribution of the dual code,
oscillating sums over weight layers of the Hamming space,
orthogonal polynomials on a finite set,
the generating function which produces the MacWilliams variable substitution.
Concepts seen in this part
In this part, while aiming at a proof of the MacWilliams identity, we introduced the basic tools around Krawtchouk polynomials. Here is the summary.
- Weight distribution
This is the sequence defined for a code by
The weight enumerator packages the weight distribution as a polynomial in two variables.
- Krawtchouk polynomials
First define their values at weights by the generating function
By the explicit formula, these values come from polynomials in . In coding theory, one mainly uses them by substituting weights for .
- Explicit formula
Krawtchouk polynomials can be written as
This can be interpreted as a sum in which binomial coefficients counting the ways coordinates overlap are combined with signed contributions coming from character values.
- Orthogonality
are orthogonal on the finite set with weights
This weight is the number of words of weight in the Hamming space.
- Krawtchouk transform
This is the transform defined for a vector by
Applying this transform twice multiplies the vector by .
- Coefficient-level MacWilliams identity
If and , then
This means that the weight distribution of the dual code is obtained by applying the Krawtchouk transform to the weight distribution of the original code.
At first, orthogonal polynomials may look like analytic objects. However, Krawtchouk polynomials are highly discrete orthogonal polynomials: their orthogonality is expressed entirely by sums over a finite set. This is why they fit so well with Hamming spaces and coding theory.
Looking back at the proof family of this note
As stated at the beginning, the proof in this note can be read as an entrance to
the orthogonal-polynomial and association-scheme approach.
On the surface, it is a coefficient calculation using Krawtchouk polynomials. We also used character sums as a minimal tool to prove the coefficient-level MacWilliams identity. But at a deeper level, the orthogonal polynomials attached to the distance structure of the Hamming space control the transform of weight distributions.
The main point of the proof in this note can be summarised in one sentence:
The MacWilliams identity is the Krawtchouk transform on weight distributions.
From the Fourier viewpoint, one handles a transform on the whole of . In the viewpoint of this note, that information has been compressed down to “weights only”. Instead of distinguishing all words, we look only at the coefficients for weights . In this compressed world, Krawtchouk polynomials appear as the shadow of the Fourier-type transform.
This viewpoint naturally leads, in a more advanced direction, to association schemes. In the Hamming space, pairs of words can be divided according to whether their distance is . The commutative algebra built from these relations is the Bose–Mesner algebra of the Hamming association scheme. The eigenvalues which appear there are precisely the Krawtchouk polynomials. Delsarte [Del73] is the classical starting point for Delsarte's association-scheme approach to coding theory, and Delsarte–Levenshtein [DL98] surveys the relationship between association schemes and coding theory. Levenshtein [Lev95] is also a representative reference for the appearance of Krawtchouk polynomials in bounds for codes and designs in the Hamming space.
Further direction: towards association schemes
We have now completed the viewpoint on the MacWilliams identity using Krawtchouk polynomials, which was the aim of this note. From here, as a more advanced viewpoint, let us introduce the direction of reinterpreting the Krawtchouk polynomials appearing in this note in the language of association schemes.
In the proof in this note, we defined Krawtchouk polynomials by a generating function and used them as transform coefficients for weight distributions. But why are these polynomials naturally attached to the Hamming space? The answer lies in the matrices built from distance relations in the Hamming space.
Take the set of all words of length as the vertex set, and write for the matrix which records whether the distance between two words is . Here is the adjacency matrix of the distance relation. These matrices form a mutually commuting algebra. When this algebra is simultaneously diagonalised, Krawtchouk polynomials appear as its eigenvalues.
Thus, in the more advanced viewpoint, the main flow is
Hamming distance → adjacency matrices → Bose–Mesner algebra → Krawtchouk polynomials as eigenvalues
The MacWilliams identity appears in this eigenvalue theory as the dual transform of weight distributions.
Even for the same Krawtchouk polynomials, the view changes substantially depending on whether one sees them, as in this note, as “orthogonal polynomials defined by a generating function”, or more advancedly as “eigenvalues of the Hamming scheme”. This difference is the natural entrance to association schemes.
References
- [Kra29] M. Krawtchouk. Sur une généralisation des polynômes d'Hermite. Comptes rendus hebdomadaires des séances de l'Académie des sciences, vol. 189, pp. 620–622, 1929 ↩
- [KLS10] Roelof Koekoek, Peter A. Lesky, and René F. Swarttouw. Hypergeometric orthogonal polynomials and their q-analogues. Springer-Verlag, Berlin, pp. xx+578, 2010. doi:10.1007/978-3-642-05014-5 ↩
- [MS77] F. J. MacWilliams and N. J. A. Sloane. The theory of error-correcting codes. I. North-Holland Publishing Co., Amsterdam-New York-Oxford, vol. Vol. 16, pp. i–xv and 1–369, 1977 ↩
- [Del73] P. Delsarte. An algebraic approach to the association schemes of coding theory. Philips Res. Rep. Suppl., no. 10, pp. vi+97, 1973 ↩
- [DL98] Philippe Delsarte and Vladimir I. Levenshtein. Association schemes and coding theory. IEEE Trans. Inform. Theory, vol. 44, no. 6, pp. 2477–2504, 1998. doi:10.1109/18.720545 ↩
- [Lev95] Vladimir I. Levenshtein. Krawtchouk polynomials and universal bounds for codes and designs in Hamming spaces. IEEE Trans. Inform. Theory, vol. 41, no. 5, pp. 1303–1321, 1995. doi:10.1109/18.412678 ↩
This series
A Series Learning through the MacWilliams Identity · Part 4 of 12
Disclaimer
Articles on this site are based on the operator's personal understanding, investigation, and research notes. I try to keep the content accurate, but it may contain errors or incomplete explanations. I do not guarantee its accuracy, completeness, usefulness, or currentness.
Please use the information on this site at your own judgment and responsibility. To the extent permitted by law, the operator is not liable for damages, losses, or disadvantages arising from using, or being unable to use, information on this site.
If you notice an error, unclear explanation, broken link, or insufficient citation, please contact the operator. I will review the content and, when appropriate, correct, update, or remove it.