Week 9 Cyclic codes

Version 2023-11-12. To PDF of this week only Open the whole set of notes in PDF

Synopsis. Cyclic codes form a subclass of linear codes. Cyclic codes are easy to define, but to reveal their advantages, one needs to study them using polynomials. We identify Fqn with the space Rn of polynomials in Fq[x] of degree less than n, so that a linear code of length n becomes a subspace of Rn. We prove that cyclic codes are subspaces of very special form: a cyclic code C consists of all multiples, in Rn, of its generator polynomial g(x). We also define a check polynomial of C. We can classify cyclic codes of length n by listing all monic divisors of the polynomial xn1 in Fq[x]. Theory and applications of cyclic codes are underpinned by the Division Theorem for polynomials and the long division algorithm, which we review here.

Definition: cyclic shift, cyclic code

For a vector a=(a0,a1,,an1)Fqn, we denote s(a)=(an1,a0,,an2) and call the vector s(a) the cyclic shift of a.

A cyclic code in Fqn is a linear code C such that aC, s(a)C.

Equivalently, a cyclic code is a linear code C such that s(C)=C.

Remark: We can iterate the cyclic shift, so if a cyclic code C contains (a0,a1,,an1), then C also contains the vectors (an2,an1,a0,,an3), , (a1,,an1,a0).

Vectors as polynomials

To study cyclic codes, we will identify vectors of length n with polynomials of degree <n with coefficients in the field Fq:

a=(a0,a1,,an1)a(x)=a0+a1x++an1xn1Fq[x]

Here Fq[x] is the ring of polynomials in one variable, x, with coefficients in Fq.

Notation: the polynomial a(x) and the vector a

If n is given and a(x) is a polynomial of degree less than n, a (same letter, underlined) will denote the vector which corresponds to a(x) in Fqn.

Example: E3 is a cyclic code

Show that the binary even weight code E3={000,110,011,101}F23 is cyclic. List the code polynomials of E3.

Solution. We know that E3 is a linear code. It is closed under the cyclic shift: 000 is invariant under the cyclic shift, and 110s011s101. Hence E3 is a cyclic code:

.
Codevector Code polynomial Remark
000 0
110 1+x
011 x+x2 =x(1+x)
101 1+x2 =(1+x)(1+x)

We will soon explain the notable fact that all code polynomials of E3 are multiples of 1+x.

The Division Theorem for polynomials

In general we cannot divide f(x) by g(x) in Fq[x] and expect to get a polynomial. However, just as the ring Z of integers, the ring Fq[x] has an extra operation called division with remainder, as per the following

Theorem 9.1: Division Theorem for polynomials

For all f(x)Fq[x], g(x)Fq[x]{0}, there exist unique Q(x),r(x)Fq[x] with

f(x)=g(x)Q(x)+r(x)anddegr(x)<degg(x)

(possibly r(x)=0). In this case the polynomial Q(x) is the quotient, and r(x) the remainder, of f(x) when divided by g(x).

We will not prove the Division Theorem but we will note and use the practical algorithm for finding the quotient and the remainder, known as long division of polynomials.

Example: long division of polynomials

Divide x5+1 by x2+x+1 in F2[x], finding the quotient and the remainder.

Solution.

(image)

Hence x5+1=(x2+x+1)Q(x)+r(x) in F2[x], with Q(x)=x3+x2+1 and r(x)=x.

This example shows long division of polynomials over F2. Division by a fixed binary polynomial is widely implemented in electronic circuits at hardware level, by means of shift feedback registers. We will soon see why such implementations are needed.

The generator polynomial of a cyclic code

In what follows, Rn denotes the space of polynomials of degree less than n.

Definition: generator polynomial

A generator polynomial of a cyclic code CRn, C{0} is a monic polynomial of least degree in C.
By convention, the generator polynomial of the null code {0}Rn is xn1.

Recall that a polynomial g(x) is monic if the coefficient of the highest power of x in g(x) is 1.

Lemma 9.2: existence and uniqueness of a generator polynomial

Every cyclic code C has a unique generator polynomial g(x).

  • Proof. If C={0}, by definition xn1 is the unique generator polynomial. Assume C{0}.

    Existence: take g(x)C to be a non-zero polynomial of lowest degree in C. Make g(x) monic by dividing it by its leading coefficient. This does not change the degree, so we now have a monic polynomial of least degree in C. Existence is proved.

    Uniqueness: let g1(x)C be another generator polynomial, then by definition g1(x) is monic and has the same degree as g(x). So f(x)=g1(x)g(x) has degree less than degg(x) (because the leading term xdegg cancels due to subtraction). Note that f(x)C because C is linear. If f(x)0, divide f(x) by its leading coefficient and obtain a monic polynomial, again in C, of degree less than degg. This contradicts the choice of g(x). Hence f(x) must be 0, and g1(x)=g(x). Uniqueness is proved.

Theorem 9.3: properties of the generator polynomial

Let CRn be a cyclic code with generator polynomial g(x). Write degg=nk. Then

  • 1. C={u(x)g(x):u(x)Rk}, i.e., the code polynomials of C are all possible multiples of g(x) of degree less than n.

  • 2. g(x) is a monic factor of the polynomial xn1 in Fq[x].

  • Proof. Both claims are trivially true when C={0} and g(x)=xn1, so assume C{0}.

    1. Observe that, writing elements of C as vectors, we have

    g=(g0,g1,,gnk,0,0,,0k1 zeros)

    and, as long as ik1,

    xig=(0,,0i zeros,g0,g1,,gnk,0,,0k1i zeros).

    That is, xig is obtained from g by applying the cyclic shift i times. Since C is cyclic, this means that xg(x),,xk1g(x)C.

    Now, every polynomial u(x)Rk — that is, a polynomial of degree less than k — is written as u0+u1x++uk1xk1 for some u0,,uk1Fq. Hence u(x)g(x) is a linear combination of the polynomials g(x), xg(x),,xk1g(x) which are in C, and, as C is linear, u(x)g(x)C. We proved that C{u(x)g(x):u(x)Rk}.

    Let us show that C{u(x)g(x):u(x)Rk}. Take f(x)C and apply the Division Theorem for polynomials to write r(x)=f(x)g(x)Q(x) where degr(x)<degg(x). We will get degQ=degfdegg<n(nk)=k and so, by what has already been proved, g(x)Q(x)C. Then by linearity r(x)C. We have seen already that there cannot be a non-zero polynomial in C of degree strictly less than degg, so r(x)=0 and f(x)=g(x)Q(x) is a multiple of g(x), as claimed. Part 1 of the Theorem is proved.

    2. Continuing from the above, observe that

    s(xk1g)=(gnk,0,,0k1 zeros,g0,g1,,gnk1)

    where s is the cyclic shift. Hence the vector s(xk1g) corresponds to the polynomial

    gnk+xk(g0+g1x++gnk1xnk1)

    which can be written as

    gnk+xkg(x)gnkxn=xkg(x)(xn1),

    as gnk=1 given that g(x) is monic. Since C is cyclic, s(xk1g)C and so xkg(x)(xn1)C. Then by Part 1, xkg(x)(xn1)=u(x)g(x) for some polynomial u(x), and so xn1=(xku(x))g(x) which shows that g(x) is indeed a factor of xn1.

Example: the generator polynomial of E3

The code E3 as a subspace of F2[x] consists of polynomials 0, 1+x, x+x2=x(1+x) and 1+x2=(1+x)2. The generator polynonial of E3 is g(x)=1+x of degree 1.

As we have already noted, all the code polynomials of E3 are multiples of 1+x.

Error detection by a cyclic code

Theorem 9.3 means that if C is a cyclic code, there is no need to store a check matrix for error detection. To determine whether the received vector y is a codevector, divide the polynomial y(x) by the generator polynomial g(x); the remainder is 0, if and only if yC.

This is how error detection is implemented in practice for binary cyclic codes (e.g., in Ethernet networks). Long division by g(x) is implemented by circuitry.

Nevertheless, for theoretical purposes we would like to have generator and check matrices for a cyclic code with a given generator polynomial.

The check polynomial

Definition: check polynomial

Let g(x) be the generator polynomial of a cyclic code CFqn. The polynomial h(x) defined by g(x)h(x)=xn1 is the check polynomial of C.

Note that if degg(x)=nk, then degh(x)=k, and h is monic.

Theorem 9.4: a generator matrix and a check matrix for a cyclic code

Let CFqn be a cyclic code with generator polynomial g(x)=g0+g1x++gnkxnk and check polynomial h(x)=h0+h1x++hkxk.

The vector g and its next k1 cyclic shifts form a generator matrix for C:

G=[g0g1gnk000g0g1gnk000g0gnk](k rows).

The vector of the polynomial

h(x)=hk+hk1x++h0xk,

obtained from h(x) by reversing the order of the coefficients, and its next nk1 shifts form a check matrix for C:

H=[1hk1h1h00001hk1h1h00001h1h0](nk rows).

  • Proof. The rows of G are linearly independent and the rows of H are linearly independent. Indeed, H is a matrix in a row echelon form with no zero rows, and so is G up to scaling of rows by a non-zero scalar g0: note that g0h0=g(0)h(0)=0n10.

    The linearly independent rows of G correspond to the polynomials g(x),xg(x),,xk1g(x) and so they span {u(x)g(x):degu(x)<k} which by Theorem 9.3 is C. Thus, G is a generator matrix for C.

    Since the number of rows of H is nk=dimC and the rows are linearly independent, to show that H is a check matrix it is enough to show that HGT=0, same as in the proof of Theorem 7.1.

    We express the inner product of vectors in terms of polynomials: if a,bFqn, then

    ab=coefficient of xn1 in a(x)b(x).

    Indeed, with a=(a0,a1,,an1) and b=(bn1,,b1,b0) one has ab=a0bn1++an1b0 which is exactly the coefficient of xn1 in the product of the polynomials a(x) and b(x).

    Number the rows of G from 0 to k1, the rows of H from 0 to nk1. The rows of G are xig, and the rows of H are the vectors of xjh written backwards. So an entry of HGT, which as we know is an inner product of a row of G and a row of H, is the coefficient of xn1 in xig(x)xjh(x)=xn+i+jxi+j. But since n+i+j>n1 and i+j<n1, this coefficient is zero, proving HGT=0.

Remark: this is not the only generator matrix (resp., check matrix) for C. As we know, a generator matrix is not unique. Moreover, these matrices are not usually in standard form. Note that a generator polynomial of C is unique.

Corollary 9.5: generator polynomial of C

C is also a cyclic code with generator polynomial h01h(x). (Scaling by h01 is necessary because the generator polynomial must by definition be monic.)

Example: cyclic binary codes of length 3

Use Theorem 9.3 and Theorem 9.4 to find all the cyclic binary codes of length 3.

Solution. Generator polynomials are monic factors of xn1 in Fq[x]. The first step is to factorise xn1 into irreducible monic polynomials in Fq[x]. A polynomial is irreducible if it cannot be written as a product of two polynomials of positive degree.

Note that the polynomial xn1 is not irreducible in Fq[x]. Indeed, xn1=(x1)(xn1++x+1).

We work over the field F2 and observe:

x31=(x1)(x2+x+1).

The polynomial x1=x+1 is irreducible, because it is of degree 1.

Can we factorise the polynomial x2+x+1 in F2[x]? If we could, we would have a factorisation (x+a)(x+b). But then ab=1 which means a=b=1 in F2. Note that (x+1)2=x2+1 in F2[x]. We have shown that x2+x+1 is irreducible in F2[x].

So the possible monic factors of x31 in F2[x] are:

1;1+x;1+x+x2;1+x3.

We now list every cyclic code in F23, giving its generator matrix G, minimum distance d and a well-known name of the code, and point out its dual code (which is also cyclic).

  • g(x)=1, G=[100010001] which corresponds to the trivial binary code of length 3: C=F23 with d=1. The dual code of F23 is the null code (see below).

  • g(x)=1+x, G=[110011]. This is {000,110,011,101}=E3, the binary even weight code of length 3 which has d=2. The dual of E3 is Rep(3,F2) (see below).

  • g(x)=1+x+x2, G=[111]. This is {000,111}=Rep(3,F2), the binary repetition code of length 3 with d=3. This code is (E3).

  • g(x)=1+x3. Theorem 9.4 returns matrix G with k=33=0 rows, G=[      ]. And indeed, by definition 1+x3 is the generator polynomial of the null code {000}, which has empty generator matrix. It is a useless code but formally it is a linear and cyclic code, so we have to allow it for reasons of consistency. The minimum distance of the zero code is undefined. This code is (F23).