# Polynomial code

In coding theory, a polynomial code is a type of linear code whose set of valid code words consists of those polynomials (usually of some fixed length) that are divisible by a given fixed polynomial (of shorter length, called the generator polynomial).

## Definition

Fix a finite field ${\displaystyle GF(q)}$, whose elements we call symbols. For the purposes of constructing polynomial codes, we identify a string of ${\displaystyle n}$ symbols ${\displaystyle a_{n-1}\ldots a_{0}}$ with the polynomial

${\displaystyle a_{n-1}x^{n-1}+\cdots +a_{1}x+a_{0}.\,}$

Fix integers ${\displaystyle m\leq n}$ and let ${\displaystyle g(x)}$ be some fixed polynomial of degree ${\displaystyle m}$, called the generator polynomial. The polynomial code generated by ${\displaystyle g(x)}$ is the code whose code words are precisely the polynomials of degree less than ${\displaystyle n}$ that are divisible (without remainder) by ${\displaystyle g(x)}$.

## Example

Consider the polynomial code over ${\displaystyle GF(2)=\{0,1\}}$ with ${\displaystyle n=5}$, ${\displaystyle m=2}$, and generator polynomial ${\displaystyle g(x)=x^{2}+x+1}$. This code consists of the following code words:

${\displaystyle 0\cdot g(x),\quad 1\cdot g(x),\quad x\cdot g(x),\quad (x+1)\cdot g(x),}$
${\displaystyle x^{2}\cdot g(x),\quad (x^{2}+1)\cdot g(x),\quad (x^{2}+x)\cdot g(x),\quad (x^{2}+x+1)\cdot g(x).}$

Or written explicitly:

${\displaystyle 0,\quad x^{2}+x+1,\quad x^{3}+x^{2}+x,\quad x^{3}+2x^{2}+2x+1,}$
${\displaystyle x^{4}+x^{3}+x^{2},\quad x^{4}+x^{3}+2x^{2}+x+1,\quad x^{4}+2x^{3}+2x^{2}+x,\quad x^{4}+2x^{3}+3x^{2}+2x+1.}$

Since the polynomial code is defined over the Binary Galois Field ${\displaystyle GF(2)=\{0,1\}}$, polynomial elements are represented as a modulo-2 sum and the final polynomials are:

${\displaystyle 0,\quad x^{2}+x+1,\quad x^{3}+x^{2}+x,\quad x^{3}+1,}$
${\displaystyle x^{4}+x^{3}+x^{2},\quad x^{4}+x^{3}+x+1,\quad x^{4}+x,\quad x^{4}+x^{2}+1.}$

Equivalently, expressed as strings of binary digits, the codewords are:

${\displaystyle 00000,\quad 00111,\quad 01110,\quad 01001,}$
${\displaystyle 11100,\quad 11011,\quad 10010,\quad 10101.}$

Note that this, as every polynomial code, is indeed a linear code, i.e., linear combinations of code words are again code words. In a case like this where the field is GF(2), linear combinations are found by taking the XOR of the codewords expressed in binary form (e.g. 00111 XOR 10010 = 10101).

## Encoding

In a polynomial code over ${\displaystyle GF(q)}$ with code length ${\displaystyle n}$ and generator polynomial ${\displaystyle g(x)}$ of degree ${\displaystyle m}$, there will be exactly ${\displaystyle q^{n-m}}$ code words. Indeed, by definition, ${\displaystyle p(x)}$ is a code word if and only if it is of the form ${\displaystyle p(x)=g(x)\cdot q(x)}$, where ${\displaystyle q(x)}$ (the quotient) is of degree less than ${\displaystyle n-m}$. Since there are ${\displaystyle q^{n-m}}$ such quotients available, there are the same number of possible code words. Plain (unencoded) data words should therefore be of length ${\displaystyle n-m}$

Some authors, such as (Lidl & Pilz, 1999), only discuss the mapping ${\displaystyle q(x)\mapsto g(x)\cdot q(x)}$ as the assignment from data words to code words. However, this has the disadvantage that the data word does not appear as part of the code word.

Instead, the following method is often used to create a systematic code: given a data word ${\displaystyle d(x)}$ of length ${\displaystyle n-m}$, first multiply ${\displaystyle d(x)}$ by ${\displaystyle x^{m}}$, which has the effect of shifting ${\displaystyle d(x)}$ by ${\displaystyle m}$ places to the left. In general, ${\displaystyle x^{m}d(x)}$ will not be divisible by ${\displaystyle g(x)}$, i.e., it will not be a valid code word. However, there is a unique code word that can be obtained by adjusting the rightmost ${\displaystyle m}$ symbols of ${\displaystyle x^{m}d(x)}$. To calculate it, compute the remainder of dividing ${\displaystyle x^{m}d(x)}$ by ${\displaystyle g(x)}$:

${\displaystyle x^{m}d(x)=g(x)\cdot q(x)+r(x),\,}$

where ${\displaystyle r(x)}$ is of degree less than ${\displaystyle m}$. The code word corresponding to the data word ${\displaystyle d(x)}$ is then defined to be

${\displaystyle p(x):=x^{m}d(x)-r(x),\,}$

Note the following properties:

1. ${\displaystyle p(x)=g(x)\cdot q(x)}$, which is divisible by ${\displaystyle g(x)}$. In particular, ${\displaystyle p(x)}$ is a valid code word.
2. Since ${\displaystyle r(x)}$ is of degree less than ${\displaystyle m}$, the leftmost ${\displaystyle n-m}$ symbols of ${\displaystyle p(x)}$ agree with the corresponding symbols of ${\displaystyle x^{m}d(x)}$. In other words, the first ${\displaystyle n-m}$ symbols of the code word are the same as the original data word. The remaining ${\displaystyle m}$ symbols are called checksum digits or check bits.

### Example

For the above code with ${\displaystyle n=5}$, ${\displaystyle m=2}$, and generator polynomial ${\displaystyle g(x)=x^{2}+x+1}$, we obtain the following assignment from data words to codewords:

• 000 ↦ 00000
• 001 ↦ 00111
• 010 ↦ 01001
• 011 ↦ 01110
• 100 ↦ 10010
• 101 ↦ 10101
• 110 ↦ 11011
• 111 ↦ 11100

## Decoding

An erroneous message can be detected in a straightforward way through polynomial division by the generator polynomial resulting in a non-zero remainder.

Assuming that the code word is free of errors, a systematic code can be decoded simply by stripping away the ${\displaystyle m}$ checksum digits.

If there are errors, then error correction should be performed before decoding. Efficient decoding algorithms exist for specific polynomial codes, such as BCH codes.

## Properties of polynomial codes

As for all digital codes, the error detection and correction abilities of polynomial codes are determined by the minimum Hamming distance of the code. Since polynomial codes are linear codes, the minimum Hamming distance is equal to the minimum weight of any non-zero codeword. In the example above, the minimum Hamming distance is 2, since 01001 is a codeword, and there is no nonzero codeword with only one bit set.

More specific properties of a polynomial code often depend on particular algebraic properties of its generator polynomial. Here are some examples of such properties:

• A polynomial code is cyclic if and only if the generator polynomial divides ${\displaystyle x^{n}-1}$.
• If the generator polynomial is primitive, then the resulting code has Hamming distance at least 3, provided that ${\displaystyle n\leq 2^{m}-1}$.
• In BCH codes, the generator polynomial is chosen to have specific roots in an extension field, in a way that achieves high Hamming distance.

The algebraic nature of polynomial codes, with cleverly chosen generator polynomials, can also often be exploited to find efficient error correction algorithms. This is the case for BCH codes.

## Specific families of polynomial codes

• Cyclic codes – every cyclic code is also a polynomial code; a popular example is the CRC code.
• BCH codes – a family of cyclic codes with high Hamming distance and efficient algebraic error correction algorithms.
• Reed–Solomon codes – an important subset of BCH codes with particularly efficient structure.

## References

• W.J. Gilbert and W.K. Nicholson: Modern Algebra with Applications, 2nd edition, Wiley, 2004.
• R. Lidl and G. Pilz. Applied Abstract Algebra, 2nd edition. Wiley, 1999.