**Theorem 6:** *If the generator polynomial g(x) of C has degree n-k then C is an (n,k)-cyclic
code. If g(x) = a _{0} + a_{1}x + a_{2}x^{2} + ... + a_{n-k} x^{n-k} then a generator matrix for C is the k x n matrix,*

*Proof:* The vectors g(x), xg(x), x^{2}g(x), ..., x^{k-1}g(x) are linearly independent. If not, there would
exist coefficients {b_{i}} so that

b_{0}g(x) + b_{1}xg(x) + b_{2} x^{2} g(x) + ... + b_{k-1} x^{k-1} g(x) = 0,

(b_{0} + b_{1}x + b_{2}x^{2} + ... + b_{k-1} x^{k-1}) g(x) = 0.

But this product has degree k - 1 + n - k = n - 1 < n, so it can not be = 0 mod (x^{n} - 1) unless
all the b_{i} = 0.

Let c(x) be in C, then c(x) = b(x) g(x) and we may assume that b(x) has degree <= k - 1
(otherwise the product will have degree > n - 1 and we would reduce modulo (x^{n} - 1) to get a
b'(x) which satisfies this degree constraint). Thus, c(x) can be written as a linear combination
of the x^{i} g(x).

The set of {x^{i} g(x) }, 0 <= i <= k - 1 is thus a basis for C and so this cyclic code has
dimension k.

Now that we have a polynomial approach to describe a cyclic code C, we consider the related
polynomial representation of the dual code C^{perp} of C. We shall see that C^{perp} is a cyclic code if
C is cyclic.

Consider h(x) = (x^{n} - 1)/g(x) where g(x) is the generator of C. If the deg g(x) = n - k, then
deg h(x) = k and it is also monic, so h(x) generates a cyclic code C' of dimension n - k. Now
consider c_{1}(x) = a_{1}(x)g(x) in C and c_{2}(x) = a_{2}(x)h(x) in C'. Then

c_{1}(x) c_{2}(x) = a_{1}(x)g(x)a_{2}(x)h(x) = a_{1}(x)a_{2}(x)f(x) = 0 (mod f(x)),

where f(x) = x^{n} - 1. Therefore, using polynomial multiplication mod f(x), any codeword from
C multiplies with any codeword from C' to give the polynomial 0. Does this imply that C' is
the dual code of C? Unfortunately no, since the isomorphism that we set up does not preserve
inner products. However, we now show that the codes C' and C are closely related - they are
equivalent codes.

Consider two vectors

**a** = (a_{0} a_{1} ... a_{n-1}) in C

and

** b** = (b_{0} b_{1} ... b_{n-1}) in C',

and the corresponding polynomial product

for some c_{i} in F. The constant term in this product is

c_{0} = a_{0} b_{0} + a_{1}b_{n-1} + a_{2} b_{n-2} + ... + a_{n-1} b_{1},

since x^{n} = 1 (mod f(x)). Now c_{0} can be written as the inner product

c_{0} = **a b'**

where** b'** is the vector obtained from **b** by cyclically shifting **b** one position to the left and
then reversing the order of the components (i.e., (b_{0} b_{n-1} b_{n-2} ... b_{1})). Observe that multiplying
the polynomial [sum from {i=0} to {n-1} c_{i} x^{i}] by x^{n-t} results in c_{t} being the constant term, and hence the constant term in the product a(x)(x^{n-t} b(x)). Therefore,

c_{t} = **a b'**

where **b'** is now the vector associated with x^{n-t} b(x). In terms of b(x),** b'** is the vector
obtained by cyclically shifting **b** t+1 positions to the left and then reversing the order of the
components.

**Example:** Consider n = 3, and the vectors **a** = (a_{0} a_{1} a_{2}) and **b** = (b_{0} b_{1} b_{2}). Then modulo x^{3} - 1,

a(x)b(x) = (a_{0} + a_{1}x + a_{2} x^{2})(b_{0} + b_{1}x + b_{2} x^{2})

= (a_{0} b_{0} + a_{1}b_{2} + a_{2} b_{1}) + (a_{0} b_{1} + a_{1} b_{0} + a_{2} b_{2})x + (a_{0} b_{2} + a_{1} b_{1} + a_{2} b_{0})x^{2}.

The coefficient of x^{2} is **a**(b_{2} b_{1} b_{0}). This **b** vector is obtained from **b** by shifting 3 ( = 2 + 1) positions to the left (putting **b** back into its original order) and then reversing the order of the
components from last to first. The b-vector in the x coefficient is obtained from **b** by shifting
2 ( = 1 + 1) to the left, obtaining (b_{2} b_{0} b_{1}) and then reversing the components.

Now since a(x)b(x) = 0 mod (x^{n} - 1), the coefficient of each power of x must be 0. From the
discussion above, this implies that **ac** = 0 (i.e., **a** and **c** are orthogonal) whenever **c** is any
cyclic shift of the vector obtained from** b** by reversing the components of** b**. Since h(x)
generates C', {h(x), xh(x), ..., x^{n-k-1}h(x) } is a basis for C' and G' = [h(x), xh(x), ..., x^{n-k-1}h(x)]^{t}
is a generator matrix for C'. Now G' generates the code C' which has the same dimension
n - k as C . Furthermore, taking b(x) in the above arguments to be h(x) itself, we see that the
reverse of every vector in C' is orthogonal to every vector in C. It follows that if we reorder
the columns of G' last to first, we obtain a matrix H which generates C , and hence is the
parity-check matrix for C.

**Example:** Suppose we wish to construct a generator matrix and a parity-check matrix for a
(7,4)- binary cyclic code. Since g(x) = 1 + x + x^{3} divides f(x) = x^{7} - 1, g(x) generates a (7,4)
- cyclic code C. h(x) = f(x)/g(x) = 1 + x + x^{2} + x^{4} generates a (7,3)-cyclic code C'. A
generator matrix for C is

A generator matrix for C' is

Writing the columns of G' last to first, a generator matrix for C^{perp} is

A simple check verifies that GH^{t} = 0.

Since C' and C^{perp} can be obtained from each other by simply reversing the components in all
vectors, C' and C^{perp} are equivalent codes. Recalling a definition that we have seen before,

**Definition **: Let h(x) = a_{0} + a_{1} x + ... + a_{k} x^{k} be a polynomial of degree k (a_{k} not 0). Define the
*reciprocal polynomial* h_{R} (x) of h(x) by

Note that h_{R}(x) = x^{k} h(1/x), where k = deg h(x). With this we may summarize the preceding
discussion with the following result.

**Theorem 7** : *Let g(x) be a monic divisor of f(x) = x ^{n} - 1 of degree n-k, and hence the
generator for a cyclic (n,k)-code C. Let h(x) = f(x)/g(x). Then h_{R}(x), the reciprocal polynomial
of h(x), generates C^{perp} .*

x^{n-k+i} = q_{i}(x)g(x) + r_{i}(x)

where deg r_{i}(x) < deg g(x) = n-k or r_{i}(x) = 0. Then

x^{n-k+i} - r_{i}(x) = q_{i}(x)g(x) in C

is a set of k linearly independent code words and the matrix whose rows are these codewords is a generator matrix of the required form.

**Example**: Consider the binary (7,4)-cyclic code generated by g(x) = 1 + x + x^{3}. By the
division algorithm we compute,

x^{3} = (1)(x^{3} + x + 1) + (1+ x)

x^{4} = (x)(x^{3} + x + 1) + (x + x^{2})

x^{5} = (x^{2} + 1)(x^{3} + x + 1) + (1 + x + x^{2})

x^{6} = (x^{3} + x + 1)(x^{3} + x + 1) + (1 + x^{2}).

A generator matrix for this code is

1 1 0 1 0 0 0 1 1 0 0 1 1 0 1 0 0 0 1 1 G = 1 1 1 0 0 1 0 = [R INotice that the rows of R are just the remainder polynomials._{4}] where R = 1 1 1 1 0 1 0 0 0 1 1 0 1 .

The corresponding parity-check matrix for this generator is H = [I_{n-k} -R^{t}]. A reason for
making this selection is that it affords a convenient polynomial interpretation for the
syndrome of a vector.

**Theorem 8 **: Let r(x) and s(x) be the respective polynomial representations of a vector **r** and
its syndrome **s** = H**r**^{t}. Then s(x) is the remainder polynomial when r(x) is divided by g(x).

**Proof:** Suppose r(x) = a_{0} + a_{1} x + ... + a_{n-1} x^{n-1}. Noting that column i, 0 <= i <= n-k-1, of H
corresponds to the polynomial x^{i} and column j, n-k <= j <= n-1, corresponds to r_{j-n+k}(x), so that

where h(x) = a_{n-k} q_{0}(x) + ... + a_{n-1} q_{k-1}(x). Thus r(x) = h(x)g(x) + s(x). Since deg r_{i}(x) <= n-k-1, it
follows that deg s(x) <= n-k-1. By the uniqueness of the quotient and remainder in the division
algorithm for polynomials, we conclude that s(x) is the remainder when r(x) is divided by
g(x).

Therefore the syndrome of a vector can be determined by polynomial division. Furthermore, the syndrome of a vector and its cyclic shift are closely related. Suppose

r(x) = q(x)g(x) + s(x),

where deg s(x) is at most n-k-1. By the above theorem s(x) is the syndrome of r(x). Now

xr(x) = xq(x)g(x) + xs(x).

If xs(x) has degree at most n-k-1, then again by the above theorem it is the syndrome of xr(x). Otherwise, the syndrome of xr(x) is the remainder when xs(x) is divided by g(x). In this case, let

Let the (monic) generator polynomial be,

Then

where deg (xs'(x) - s_{n-k-1} g'(x)) <= n - k - 1. Now by the uniqueness of the remainder in the
division algorithm and the previous theorem, we see that the syndrome of xs(x) is
xs(x) - s_{n-k-1} g(x). We summarize this as,

**Theorem 9** :* Let C be a cyclic (n,k)-code over F with generator polynomial g(x), and let r(x)
be a polynomial with syndrome s(x) = s _{0} + s_{1} x + ... + s_{m} x^{m}. Then the syndrome of xr(x) is
*

- xs(x) if deg s(x) < n-k-1, and
- xs(x) - s
_{n-k-1}g(x), if deg s(x) = n-k-1.

1 0 0 1 0 1 1 H = [IConsider_{3}-R^{t}] = 0 1 0 1 1 1 0 . 0 0 1 0 1 1 1

r(x) = 1 + x^{2} + x^{3} + x^{5} + x^{6}.

If we divide r(x) by g(x), we get

r(x) = (x^{3} + x^{2} + x + 1)g(x) + x^{2}.

The remainder is, as expected,** s**.

Now let us compute the syndrome of a cyclic shift of **r**. Let **w** = (1101101) which
corresponds to the polynomial xr(x). H**w**^{t} = (110)^{t}. We can compute this syndrome using
polynomial operations as follows. Since deg s(x) = 2 = n-k-1, the syndrome of xr(x) is

xs(x) - 1g(x) = x^{3} - (x^{3} + x + 1) = 1 + x.

The preceding observations lead us to an interesting method of decoding certain error patterns
in cyclic codes. The technique is sometimes referred to as *error trapping*.

Suppose C is an (n,k)-code with minimum distance d = 2t + 1, and parity-check matrix
H = [I_{n-k} A]. Let** c** be a codeword and **e** an error pattern of weight at most t. If **r = c + e** is
received, then the syndrome of **r** is

s = H** r**^{t} = H (**c + e**)^{t} = H **e**^{t}.

Let **e*** = (**s**^{t}, **0**), where **0** is the k-tuple of all 0's. Then H **e***^{t} = **s**, and **e*** and **e** have the
same syndrome, so are in the same coset of C. Now suppose wt(**s**) <= t. Then wt(**e***)<= t and it
follows that **e = e*** since a coset can contain at most one vector of weight less than or equal
to t. Hence, the error is known to be **e** = (**s**^{t},0) in this case.

Now suppose C is cyclic with generating polynomial g(x). Let **e** be an error pattern of
weight at most t with a cyclic run of at least k 0's. Then there is some i, 0 <= i <= n-1, such
that a cyclic shift of **e** through i positions is a vector whose non-zero components all lie
within the first n-k components. For this i, wt(s_{i}(x)) <= t, where s_{i}(x) is the syndrome of
x^{i} e(x) mod (x^{n} - 1). If we compute s_{i}(x) as the remainder of x^{i} r(x) divided by g(x), then when
wt(s_{i}(x)) <= t, for this i by the above argument x^{i} e(x) = (s_{i},**0**). Thus e(x) = x^{n-i}(s_{i},**0**). This gives
rise to the following algorithm (stated for the binary case, but easily modifiable for the q-ary
case):

- Compute the syndrome s
_{0}(x) of r(x) from the division algorithm. - Set i = 0.
- If wt(s
_{i}(x)) <= t, then set e(x) = x^{n-i}(s_{i},**0**), and decode to r(x) - e(x). - Set i = i + 1.
- If i = n then stop; the error pattern is not trappable.
- If deg s
_{i-1}(x) < n-k-1, then set s_{i}(x) = xs_{i-1}(x); otherwise s_{i}(x) = xs_{i-1}(x) - g(x). - Go to (3).

r(x) = (x^{3} + 1)g(x) + (x + x^{2}),

so s(x) = x + x^{2}. Since the weight of s(x) is > 1 (= t), we compute the syndrome s_{1}(x) of
xr(x). As the degree of s(x) = 2 = n - k - 1, we mutiply s(x) by x and subtract g(x) to get
s_{1}(x) = 1. As this has weight 1, we obtain the error pattern

e(x) = x^{7-1}(s_{1},**0**) = x^{6}(1000000) = x^{6}.

Since for n = 7 all error patterns of weight 1 have a cyclic run of six 0's and 6 > k = 4, this technique will correct all single errors.

**Example**: g(x) = 1 + x^{4} + x^{6} + x^{7} + x^{8} generates a binary (15,7)-cyclic code. If the minimum
distance of this code is 5, then t = 2. Any (at most) weight 2 error pattern must contain a run
of at least 7 0's and so can be trapped. If a received 15-tuple is

r = (1100 1110 1100 010)

we calculate,

r(x) = (x + x^{2} + x^{4} + x^{5})g(x) + (1 + x^{2} + x^{5} + x^{7}).

We then compute the syndrome s_{i}(x) of x^{i} r(x) until wt(s_{i}(x)) <= 2.

i sThus the error pattern is_{i}(x) 0 10100101 1 11011001 2 11100111 3 11111000 4 01111100 5 00111110 6 00011111 7 10000100

**e** = x^{15-7}(s_{7},**0**) = x^{8}(100001000000000) = (0000 0000 1000 010),

and we decode r(x) to
**r - e** = (1100 1110 0100 000).