Skip to main content
KetQat

Appearance

Equation · intermediate

MacWilliams identity

The weight enumerator of the dual of a linear code is obtained from the weight enumerator of the code by a linear change of variables. The weight distribution of a code therefore determines that of its dual.

Established resultMachine-checkedUpdated 2026-12-01 · last verified 2026-12-01

AI-assisted text, machine-checked, not yet reviewed by a person. Citations resolve and an automated pass compared the statements with the cited sources. That is not peer review; check the sources for anything you depend on.

WC⊥(x,y)  =  1∣C∣  WC(x+(q−1) y,  x−y)W_{C^{\perp}}(x, y) \;=\; \frac{1}{\lvert C\rvert}\; W_{C}\bigl(x + (q-1)\,y,\; x - y\bigr)

The identity is due to MacWilliams. For binary codes it reads WC⊥(x,y)=∣C∣−1 WC(x+y, x−y)W_{C^{\perp}}(x, y) = \abs{C}^{-1}\, W_C(x + y,\, x - y).

Example. The [7,4,3][7, 4, 3] Hamming code has WC=x7+7x4y3+7x3y4+y7W_C = x^7 + 7x^4y^3 + 7x^3y^4 + y^7. Substituting,

116[(x+y)7+7(x+y)4(x−y)3+7(x+y)3(x−y)4+(x−y)7]  =  x7+7x3y4,\tfrac{1}{16}\Bigl[(x+y)^7 + 7(x+y)^4(x-y)^3 + 7(x+y)^3(x-y)^4 + (x-y)^7\Bigr] \;=\; x^7 + 7x^3y^4 ,

the weight enumerator of the [7,3,4][7, 3, 4] simplex code: its seven nonzero words all have weight 4.

Uses. Because the coefficients of WC⊥W_{C^\perp} are counts, they are nonnegative; imposing this on a hypothetical weight distribution gives linear constraints that rule out codes, the basis of linear-programming bounds. Inequivalent codes can share a weight enumerator, so the identity relates weight distributions, not codes. Shor and Laflamme found an analogous pair of enumerators and identity for quantum codes.

Holds when

  • C⊆FqnC \subseteq \F_q^n is a linear code and C⊥C^{\perp} its dual for the form x⋅y=∑ixiyix \cdot y = \sum_i x_i y_i.
  • WC(x,y)=∑c∈Cx n−wt⁡(c) ywt⁡(c)=∑w=0nAw x n−wywW_C(x, y) = \sum_{c \in C} x^{\,n - \operatorname{wt}(c)}\, y^{\operatorname{wt}(c)} = \sum_{w=0}^{n} A_w\, x^{\,n-w} y^{w}, where AwA_w is the number of codewords of weight ww.

Proof

Proof of the MacWilliams identity for binary codesMachine-checked

Let C⊆F2nC \subseteq \F_2^n be linear.

Step 1: a sum over CC of signs. For u∈F2nu \in \F_2^n,

∑c∈C(−1)u⋅c  =  {∣C∣u∈C⊥,0u∉C⊥.\sum_{c \in C} (-1)^{u \cdot c} \;=\; \begin{cases} \abs{C} & u \in C^{\perp}, \\ 0 & u \notin C^{\perp}. \end{cases}

If u∈C⊥u \in C^\perp every term is 11. Otherwise pick c0∈Cc_0 \in C with u⋅c0=1u \cdot c_0 = 1; the substitution c↦c+c0c \mapsto c + c_0 permutes CC and multiplies the sum by −1-1, so the sum is zero.

Step 2: transform of the weight function. Fix numbers x,yx, y and let f(u)=x n−wt⁡(u) ywt⁡(u)=∏i=1nf1(ui)f(u) = x^{\,n - \operatorname{wt}(u)}\, y^{\operatorname{wt}(u)} = \prod_{i=1}^n f_1(u_i) with f1(0)=xf_1(0) = x, f1(1)=yf_1(1) = y. For v∈F2nv \in \F_2^n define f^(v)=∑u∈F2n(−1)u⋅vf(u)\hat f(v) = \sum_{u \in \F_2^n} (-1)^{u \cdot v} f(u). The sum factorises over coordinates:

f^(v)  =  ∏i=1n(x+(−1)vi y)  =  (x+y) n−wt⁡(v) (x−y)wt⁡(v).\hat f(v) \;=\; \prod_{i=1}^{n} \Bigl( x + (-1)^{v_i}\, y \Bigr) \;=\; (x + y)^{\,n - \operatorname{wt}(v)}\,(x - y)^{\operatorname{wt}(v)} .

Step 3: combine. Summing f^\hat f over the code and exchanging the order of summation,

∑c∈Cf^(c)  =  ∑u∈F2nf(u)∑c∈C(−1)u⋅c  =  ∣C∣∑u∈C⊥f(u),\sum_{c \in C} \hat f(c) \;=\; \sum_{u \in \F_2^n} f(u) \sum_{c \in C} (-1)^{u \cdot c} \;=\; \abs{C} \sum_{u \in C^{\perp}} f(u) ,

by Step 1. The left side is WC(x+y, x−y)W_C(x + y,\, x - y) by Step 2 and the right side is ∣C∣ WC⊥(x,y)\abs{C}\, W_{C^{\perp}}(x, y). Since this holds for all numbers x,yx, y, it is an identity of polynomials.

Mentions

Open in the knowledge graph

Contributions about this record

Nobody has published a contribution about it yet.

Publish a result, reproduction or commentPropose a correction to this page

References

  1. Jessie MacWilliams (1963). A Theorem on the Distribution of Weights in a Systematic Code. Bell System Technical Journal 42 (1), 79-94. doi:10.1002/j.1538-7305.1963.tb04003.x
  2. W. Cary Huffman, Vera Pless (2003). Fundamentals of Error-Correcting Codes. Cambridge University Press. doi:10.1017/CBO9780511807077
  3. Peter Shor, Raymond Laflamme (1997). Quantum Analog of the MacWilliams Identities for Classical Coding Theory. Physical Review Letters 78, 1600-1602. doi:10.1103/PhysRevLett.78.1600arXiv:quant-ph/9610040

Contributors

  • KetQat maintainers · @ketqatConceptualization; Supervision (CRediT roles)
  • Claude (AI drafting assistant)Writing, original draft (CRediT roles)

Review history

  1. Automated source check · Pass · 2026-12-01 · Independent automated verification pass (AI, not the drafting session)

    Identity checked numerically: exact symbolic substitution for the [7,4,3] Hamming example (gives x^7 + 7x^3y^4) and the q-ary form verified on random ternary codes of length 5 (sympy/numpy script); attribution matches Guruswami-Rudra-Sudan, Essential Coding Theory (open draft), Ch. 2 notes; macwilliams-1963 metadata compared with Crossref; shor-laflamme-1997 arXiv quant-ph/9610040 abstract confirms the quantum analogue of the MacWilliams identities.

Revision history

  1. 2026-12-01Content release 2.1.0: 35 more topics, an independent source check of every record, intake hardening (#17)80537b7e
  2. 2026-11-30KetQat Commons: free learning paths, knowledge records, research problems, literature intake (#14)571c9b10

Current revision 2115d3e74759c868. Source file knowledge/records/equation/macwilliams-identity.md in the content repository (readable there once it is public).