You are on page 1of 65

LATIN SQUARES AND THEIR APPLICATION IN CODING THEORY

ARTEMIS TOUMAZI URN: 6084596


Supervisor: Dr. Janet Godolphin BSc Project University of Surrey May 2012 Submitted as a report for the BSc Project for the BSc degree at the University of Surrey

Displaying a 7 x 7 Latin square, this stained glass window honors Ronald Fisher, whose Design of Experiments discussed Latin squares. Fisher's student, A.W.F. Edwards, designed this window for Caius College, Cambridge. (Reference: Google Images for Latin Squares. www.google.com )

Latin Squares Artemis Toumazi

Abstract
The focus of this project is in the area of Latin Squares and their applications in Coding Theory. A Latin Square of order n, is an n x n array of n different elements, where in each row and each column the elements are never repeated. The famous Sudoku squares are examples of Latin Squares. Two Latin Squares of order n are said to be 2 orthogonal if we get n distinct ordered pairs of symbols when the squares are superimposed. Latin Squares have various applications in Coding Theory and Cryptography. In this project we construct codes from mutually orthogonal Latin Squares. We will present a study of the use and performance of these codes. The codes performances will be compared with the performance of Binary codes.The findings from this project provide evidence that the codes from mutually orthogonal Latin Squares have better performance than Binary codes.

Latin Squares Artemis Toumazi

Table of Contents
Abstract Chapter 1: Introduction
Definition ................................................................................................................................. The history of Latin Squares .............................................................................................. Some Examples ....................................................................................................................... Reduced Form ......................................................................................................................... Applications ............................................................................................................................. 1. Mathematical puzzles(Sudoku, Ken-Ken, etc) ........................................................ 2. Other Applications ....................................................................................................... Mutually orthogonal Latin Squares .................................................................................... Examples of mutually orthogonal Latin Squares ............................................................

2 4
4 4 5 6 7 7 8 8 10

Chapter 2: Construction of MOLS of order n

13

Method of Constructing a set of n-1 MOLSs of order n where n is prime .............. 13 Method of Constructing a set of n-1 MOLSs of order n where n is a power of a prime i.e

p q .............................................................................................................................. 16

Definition of irreducible polynomial and examples ........................................................ 17

Chapter 3: Coding Theory


Definition of q-ary code ....................................................................................................... Binary Codes ........................................................................................................................... Linear Codes ............................................................................................................................ Generator Matrices .............................................................................................................. Parity-Check Matrices .......................................................................................................... Codes from mutually orthogonal Latin Squares (MOLSs) ........................................... Examples ..................................................................................................................................

19
19 20 22 22 23 27 27

Chapter 4: Comparison of code performance

32

Using codes to encode mathematical sentences ............................................................. 33 Generation of Random Sequences ...................................................................................... 37 Some Examples ........................................................................................................................ 38 Compare the performance of a code from 2 non-orthogonal Latin Squares with a code from two orthogonal Latin Squares ........................................................................ 62

References
3

66

Latin Squares Artemis Toumazi

1 Introduction

Definition
A Latin Square of order n is an n x n array which has entries taken

from an n-element set S and has the property that each element from the set S occurs exactly once in each row and exactly once in each column.
They are familiar objects in algebra as multiplication tables of quasi-

groups, in geometry as coordinate systems for nets and in statistics as one of the simplest combinatorial designs. They are used extensively in the design of experiments.

The History of Latin Squares


Latin Squares have a long history, stretching back at least as far as medieval Islam (12th century) when they were used on amulets. Abu lAbbas al Buni wrote about them and constructed, for example, 4x4 Latin Squares using letters from a name of God. Albrecht Dver in his famous etching Melancholia on the 15th century artist portrays a 4x4 magic square in the background. Authur Cayley continued the work of Latin Squares and in the 1930s the concept emerged again in the guise of multiplication tables when the theory of quasi-groups and loops began to be developed as a generalization of the group concept.
4

Introduction

More recently, Ronald A. Fisher (1890-1962), and others have applied Latin squares in the fields of agronomy, computer science, number theory, graph theory, coding theory, and the design and statistical analysis of scientific experiments.

Examples of Latin Squares


I am giving one example of a Latin Squares from each main class up to order 5. For n=1 1

For n=2 1 2 For n=3 1 2 3 2 3 1 3 1 2 2 1

For n=4 1 2 3 4 2 1 4 3 3 4 1 2 4 3 2 1 OR 1 2 3 4 2 4 1 3 3 1 4 2 4 3 2 1

Latin Squares Artemis Toumazi

For n=5 1 2 3 4 5 2 3 5 1 4 3 5 4 2 1 4 1 2 5 3 5 4 1 3 2 OR 1 2 3 4 5 2 4 5 1 3 3 1 4 5 2 4 5 2 3 1 5 3 1 2 4

Reduced form
A Latin Squares is said to be reduced (either normalized or in standard form) if the elements of its first row and the elements of its first column are in natural order. All the examples given so far are examples of reduced Latin Squares.

For example, the below Latin Square is not reduced because its first column is A,C,B rather than A,B,C. A C B B A C C B A

We can make any Latin Square reduced by reordering the rows and columns. For example, the above Latin Square can reduced by switching the second and third rows of the matrix A B C

B C A

C A B Now this Latin Square is reduced, i.e. both its first row and its first column are alphabetically ordered A,B,C.
6

Introduction

Applications
1) Mathematical puzzles a) The popular Sudoku puzzles are a special case of Latin Squares; any solution to a Sudoku puzzle is a Latin Square. Sudoku imposes the additional restriction that sets of nine squares arranged in 3x3 structures must also contain the digits 1-9 (in the standard version) For example, below is a Sudoku puzzle.

Puzzle

Completed

(Reference: www.google.com )

b) The more recent Ken-Ken puzzles are also examples of Latin Squares. The goal of each puzzle is to fill a grid with digits : 1 through 4 for a 44 grid, 1 through 5 for a 55 grid, etc. so that no digit appears more than once in any row or column (i.e a Latin Square).

Latin Squares Artemis Toumazi

For example, consider the Ken-Ken puzzle below. Puzzle Completed

(Reference: http://puzzles.about.com/od/logicpuzzles/) 2) Other applications of Latin Squares are the design of statistical experiments, the tournament scheduling and the construction of magic squares.

Mutually orthogonal Latin Squares


Two Latin Squares are said to be orthogonal if each symbol of the first square occurs just once with each symbol of the second square as an ordered pair. The Latin Squares below provide an example of a pair of orthogonal Latin Squares of order 4.

1 2 3 4

2 1 4 3

3 4 1 2

4 3 2 1 AND

1 3 4 2

2 4 3 1

3 1 2 4

4 2 1 3

To see that squares are orthogonal, superimposing the squares, each ordered pair of labels occurs once.

Introduction

11 23 34 42

22 14 43 31

33 41 12 24

44 32 21 13

Mutually orthogonal Latin Squares(MOLS) appear in various problems. A set of Latin Squares is called mutually orthogonal if any two of the Latin Squares in the set are orthogonal to each other. The mutually orthogonal Latin Squares that are superimposed are named a GraecoLatin Squares. The previous example is such a square. Three or more mutually orthogonal Latin Squares that are superimposed gives rise to a Hyper Latin Square.

The famous Swiss mathematician Leonhard Euler began the systematic investigation of Latin Squares in 1779 and raised a problem connected with them, which is known as the thirty-six officers problem and which wasnt solved until the beginning of the 20th century. Eulers Officers Problem concerns the existence of a 6x6 array of 36 officers, 6 of each rank, from 6 distinct regiments, such that there is in each row and in each column exactly one officer of each rank and one officer from each regiment. This is obviously equivalent to the existence of two orthogonal Latin Squares of order six. Euler conjectured that no pair of MOLS of order 6 existed. He also conjectured that no pair of MOLS of order 4n+2 existed. Eulers conjecture for n=6 was verified by Tarry in 1900. It was not until 1958-1960, when the combined efforts of Bose, Shrikhande and Parker showed that Euler was wrong in all other cases.

Applications to Error Detecting and Correcting Codes


Sets of Latin Squares that are orthogonal to each other have found an application as error correcting codes. The encoding is formed from Latin Squares that are orthogonal to each other.

Latin Squares Artemis Toumazi

Examples of mutually orthogonal Latin Squares


1) Any two of text, foreground color, background color and typeface, form a pair
of orthogonal Latin Squares:

fjord jawb phleg qiviut zincky m s ox zincky fjords jawb phleg qiviu t ox m qiviu zinck fjords jawbox phleg y m t phleg qiviut zinck fjord jawbo s m y x jawbo phlegm qiviut zincky fjord x s
(Reference: Wikipedia encyclopedia: http://en.wikipedia.org ) The above table shows 4 mutually orthogonal Latin Squares of order 5, representing respectively: the text: fjords, jawbox, phlegm, qiviut, and zincky the foreground color: white, red, lime, blue, and yellow the background color: black, maroon, teal, navy, and silver the typeface: serif (Georgia / Times Roman), sans-serif (Verdana / Helvetica), monospace (Courier New), cursive (Comic Sans), and fantasy (Impact).

Due to the Latin Square property, each row and each column has all five texts, all five foregrounds, all five backgrounds, and all five typefaces.
10

Introduction

Due to the mutually orthogonal property, there is exactly one instance somewhere in the table for any pair of elements, such as (white foreground, monospace), or (fjords, navy background) etc., and also all possible such pairs of values and dimensions are represented exactly once each.

2) Two mutually orthogonal Latin Squares (MOLS) of order 3. (see below table) The latin alphabets A, B and C are symbols of the first Latin Square. The greek alphabets , and are symbols of the second Latin Square which is orthogonal to the first Latin Square (adapted from Fisher, 1960).

1 I II III A B C C A

2 C A

Theorem It is never possible to obtain a set of more than n-1 mutually orthogonal Latin Squares(MOLS) of order n. Proof: Any set of MOLS of order n is equivalent to a set in standard form, which of course has the same number of squares in it. Consider the entries in first column and second row of all of the squares in reduced form. Two squares can not have the same entry in this cell. Suppose two squares had an r in this cell, then in the superimposed square the ordered pair (r,r) would appear in this cell, also in the r-th cell of the first row because both squares have the same first row, and so, the two squares can not be orthogonal contradiction. Now, no square can have 1 as the symbol in this cell, since it appears in the first column of the first row. Thus, there are only n-1 possible entries for this cell and so there can be at most n-1 squares.

11

Latin Squares Artemis Toumazi

Alternative Proof: The result can be explained by an example of two Latin Squares (Square 1 and Square 2) of order n. Assume the squares are in standard form, then the first two rows are: 1 s Square 1 Square 2 2 3 ..... n

1 r

..... n

The element r in row 2, column 1 of square 1 cannot be 1. The element s in row 2, column 1 of square 2 cannot be 1 or r. Generally, for a given cell not in the first row, no two squares can have the same entry. If the cell is in column c, it also cannot take value c, because c is the first entry in the column. Therefore there are at most n-1 MOLS in a set of squares of order n.

Note: A set of n-1 MOLS of order n is called a complete set.

12

Latin Squares Artemis Toumazi

2 Construction of MOLS of order n


Method of constructing a set of n-1 MOLSs of order n where n is prime
We shall show the method for n=7 We construct 6 squares which each is the Cayley table for the operation ax+y (modulo n) where a {1,2,3,4,5,6}, and where x is the row number and y is the column number.

a=1 0 1 2 3 4 5 6

0 0 1 2 3 4 5 6 1

2 2 3 4 5 6 0 1

3 3 4 5 6 0 1 2

4 4 5 6 0 1 2 3

5 5 6 0 1 2 3 4

6 6 0 1 2 3 4 5 a=2 0 1 2 3 4 5 6 0 0 2 4 6 1 3 5 1 3 5 0 2 4 6 1 2 2 4 6 1 3 5 0 3 3 5 0 2 4 6 1 4 4 6 1 3 5 0 2
13

2 3 4 5 6 0

5 5 0 2 4 6 1 3

6 6 1 3 5 0 2 4

Construction of MOLS of order n

a=3 0 1 2 3 4 5 6

0 0 3 6 2 5 1 4 1

2 2 5 1 4 0 3 6

3 3 6 2 5 1 4 0

4 4 0 3 6 2 5 1

5 5 1 4 0 3 6 2

6 6 2 5 1 4 0 3

a=4 0 1 2 3 4 5 6

0 0 4 1 5 2 6 3 1

2 2 6 3 0 4 1 5

3 3 0 4 1 5 2 6

4 4 1 5 2 6 3 0

5 5 2 6 3 0 4 1

6 6 3 0 4 1 5 2

4 0 3 6 2 5

5 2 6 3 0 4

a=5 0 1 2 3 4 5 6

0 0 5 3 1 6 4 2 1

2 2 0 5 3 1 6 4

3 3 1 6 4 2 0 5

4 4 2 0 5 3 1 6

5 5 3 1 6 4 2 0

6 6 4 2 0 5 3 1

a=6 0 1 2 3 4 5 6

0 0 6 5 4 3 2 1 1

2 2 1 0 6 5 4 3

3 3 2 1 0 6 5 4

4 4 3 2 1 0 6 5

5 5 4 3 2 1 0 6

6 6 5 4 3 2 1 0

6 4 2 0 5 3

0 6 5 4 3 2

14

Latin Squares Artemis Toumazi

Are these 6 squares are mutually orthogonal? Recap: Two Latin Squares of the same size are said to be orthogonal if every possible ordered pair of symbols occurs exactly once when we overlay the two squares. Hence, the above 6 Latin Squares to be mutually orthogonal, each pair of them must be orthogonal to each other. By checking the orthogonality of the above 6 Latin Squares we can see that each pair is orthogonal, as each element appears only once, and we can deduce that those Latin Squares are a set of a mutually orthogonal Latin Squares. Checking for example a=1 with a=5 : a=1 0 1 2 3 4 5 6 0 0 1 2 3 4 5 6 1 2 3 4 5 6 0 1 2 2 3 4 5 6 0 1 3 3 4 5 6 0 1 2 4 4 5 6 0 1 2 3 5 5 6 0 1 2 3 4 6 6 0 1 2 3 4 5 a=5 0 1 0 0 5 3 1 6 4 2 1 6 4 2 0 5 3 1 2 2 0 5 3 1 6 4 3 3 1 6 4 2 0 5 4 4 2 0 5 3 1 6 5 5 3 1 6 4 2 0 6 6 4 2 0 5 3 1

2 3 4 5 6

a=1,5 0 1 2

0 0,0 1,6 2,5 3,4 4,3 5,2 6,1

1 1,1 2,0 3,6 4,5 5,4 6,3 0,2

2 2,2 3,1 4,0 5,6 6,5 0,4 1,3

3 3,3 4,5 5,1 6,0 0,6 1,5 2,4

4 4,4 5,3 6,2 0,1 1,0 2,6 3,5

5 5,5 6,4 0,3 1,2 2,1 3,0 4,6

6 6,6 0,5 1,4 We can observe that none of the ordered pairs appear twice in the new Latin Squares are orthogonal.

3 4 5 6

2,3 superimposition, therefore the two above 3,2 4,1 5,0

15

Construction of MOLS of order n

Method of constructing a set of n-1 MOLSs of order n where n is a q power of a prime i.e. p
Try the same operation when n is not a prime. We shall show the method for n=4 We construct 3 squares which each is the Cayley table for the operation ax+y (modulo 4) where a {1,2,3}, and where x is the row number and y is the column number.

a=1 0 1 2 3

0 0 1 2 3 1

2 2 3 0 1

3 3 0 1 2

a=2 0 1 2 3

0 0 2 0 2 1

2 2 0 2 0

3 3 1 3 1

a=3 0 1 2 3

0 0 3 2 1 1

2 2 1 0 3

3 3 2 1 0

2 3 0

3 1 3

0 3 2

Squares obtained with =1 and =3 are Latin Squares. I note that the square obtained with =2 is NOT a Latin Square because each column does not contain each element of {0,1,2,3}: some elements occur twice and some not at all. For example in the first column elements 0 and 2 are represented twice but the elements 1 and 3 do not occur. Are these squares mutually orthogonal? Superimposing the squares we get the array: a=1,3 0 1 2 3 0 1 2 3 We can observe that ordered pairs appear either zero times or 2 times in new superimposition. For example (3,1) occurs twice but (1,2) does not occur at all. Therefore the two above Latin Squares are NOT mutually orthogonal.

0,0 1,1 1,3

2,2 3,3 0,2

2,0 3,1

2,2 3,3 0,0 1,1 3,1 0,2 1,3 2,0

16

Latin Squares Artemis Toumazi

Therefore, amongst the set of 3 squares of order 4 obtained by the method that worked for squares of prime order, there is not even one pair of mutually orthogonal Latin Squares. Definition In mathematics, a polynomial is said to be irreducible if it cannot be factored into the product of two or more non-trivial polynomials whose coefficients are of a specified type. Thus in the common context of polynomials with rational coefficients, a polynomial is irreducible if it cannot be expressed as the product of two or more such polynomials, each of them having a lower degree than the original one. For example, the set of real numbers

x 2 + 1 is irreducible but

x 2 1 = ( x + 1)( x 1) is reducible.
A set of 3 mutually orthogonal Latin Squares of order 4 can be constructed as follows:

2 + + 1 is irreducible over arithmetic modulo 2. Use this 2 irreducible polynomial and the constraint + + 1 = 0 to construct 3 MOLS, of
The polynomial order 4. Here we work modulo 2 with the set of symbols 0,1,,+1. Multiplication Table: x 0 1 +1 0 0 0 0 0 0 1 +1 1 0 +1 1 +1 0 +1 1

Since,

2 + + 1 = 0 2 = 1 = + 1 so, = 2 = + 1 ( + 1) = 2 + = + 1 + = 2 + 1 = 1
( + 1)2 = 2 + 2 + 1 = + 1 + 2 + 1 = 3 + 2 =

The above multiplication table helps us to obtain the 3 tables: =1 0 1 +1


0 0 1 +1 1 0

+1 +1 1 0

= 0 1 +1 0

0 1

1 0 1

+1 +1 1 0
17

+1 0 1

+1 0

+1

+1 1

+1

Construction of MOLS of order n

=+1 0 1 +1 0

0 1 0

1 1

+1 +1 0 1

+1 1

+1 0

+1

The approach has generated 3 Latin Squares. Are these 3 squares mutually orthogonal? Checking for example the pair of squares with =1 and =. Superimposing the squares we get the array: a=1, 0 1 +1 0 0,0 1, ,+1 +1,1 1,1 0,+1 +1, ,0 1 , +1,0 0,1 1,+1 +1 +1,+1 ,1 1,0 0,

We can observe that none of the ordered pairs appear twice in the new superimposition, therefore the two above Latin Squares are mutually orthogonal..

The same is true for all pairs amongst the 3 squares. Therefore we have a set of 3 MOLS. Relabeling as 2 and +1 as 3, the squares are: 0 1 2 3 1 0 3 2 2 3 0 1 3 2 1 0 0 2 3 1 1 3 2 0 2 0 1 3 3 1 0 2 0 3 1 2 1 2 0 3 2 1 3 0 3 0 2 1

18

Latin Squares Artemis Toumazi

3 Coding Theory
Coding theory is the study of the properties of codes and their fitness for a specific application. Codes are used for data compression, cryptography, errorcorrection and more recently for network coding. Codes are studied by various scientific disciplinessuch as information theory, electrical engineering, mathematics, and computer sciencefor the purpose of designing efficient and reliable data transmission methods. This typically involves the removal of redundancy and the correction (or detection) of errors in the transmitted data. In this section we will compare binary codes to codes formed from mutually orthogonal Latin Squares. Definition 3.1 A q-ary code of length n is a subset C of The elements of C are called codewords.

A n , where A is the set with q elements.

When q=2 the code is called binary code.

19

Coding Theory

Binary Codes
Since computers represent data in terms of 0s and 1s we begin by considering binary codes, which consist of codewords each of whose bits is either a 0 or a 1. In this setting, the usual rules of arithmetic must be modified, since the result of each calculation involving scalars must be a 0 or a 1. The modified rules for addition and multiplication are given below: With these rules, our set of scalars {0,1} is denoted by + 0 1 integers modulo 2. In 0 1 0 1 0 1 x 0 1 0 0

2 and is called the set of


0 0 1 1

2 , 1 + 1 + 0 + 1 = 1 and 1 + 1 + 1 + 1 = 0

The code below is an example of binary code. {0000,0011,0101,0110,1001,1010,1100,1111} Definition 3.2 Each binary word in a code is a codeword. The number n of bits in each codeword of a block code is the length of the code. For example the above binary code has eight codewords and is a code of length 4. Another code of length 4 has all the 4-bit binary words as codewords: {0000,0001,0010,0011,0100,0101,0110,0111,1000,1001,1010,1011,1100,1101,1110,1111}

20

Latin Squares Artemis Toumazi

Hamming distance

The Hamming distance d(x,y) between two binary words x and y of a code is the number of places in which they differ. For example, consider the code, {0000, 0011, 0101, 0110, 1001, 1010, 1100, 1111} If x=0011 and y=1001, then x and y differ in the first and third bits, and so d(x,y)=2 Definition 3.3 The minimum distance, , of a code is the smallest Hamming distance between any two distinct codewords. For example the Hamming distances of the code {0000,0011,0101,0110,1001,1010,1100,1111} are 2,2,2,2,2,2,4,2,2,2,2,4,2,2,2,4,2,2,4,2,2,2,2,2,2,2,2,2. Therefore the minimum distance is 2 so =2 Theorem Let C be a code with minimum distance . If is odd, then C can detect and correct up to (-1)/2 errors. If is even, then C can detect up to /2 errors and correct up to (-2)/2 errors. So for the example above, is even (=2) then the code can detect 1 error and correct 0 errors. Definition 3.4 A code of length n, with k message bits , and M=2k codewords (maximum number of codewords) and minimum distance is an (n, M, ) code. The number k is the dimension of the code. For example, consider the code {0000000, 1101001, 0101010, 1000011, 1001100, 0100101, 1100110, 0001111, 1110000, 0011001, 1011010, 0110011, 0111100, 1010101, 0010110, 1111111 } This code is a binary code which has sixteen (24 ) codewords, minimum distance =3 and length 7. It is therefore a (7, 24, 3) code. Definition 3.5 The weight w(x) of a binary word x is the number of non-zero digits in x. For example, the weight of the codeword x=0101 is 2 because the non-zero digits are the second and the fourth.

21

Coding Theory

Linear Codes
Definition 3.6 A Linear Code has the property that the sum (modulo 2) of any two binary codewords is also a codeword , where x and y are codewords, then so x + y. For example, the code {0000,0101,1010,1111}, is a linear code since the sum of any two of these codewords is a codeword.

Generator Matrix
Definition 3.7 A k x n matrix G is a generator matrix for an (n, M, ) linear code C if the binary words that can be expressed as a sum of a subset of the rows of G are exactly the codewords of C. To find the generator matrix for a Linear Code we must first find the generator set for the code. Note: The generator set is the minimal set for the code since the sum of any two codewords of linear code is also a codeword. For example , the generator set for the code {000000, 001110, 010101, 011011, 100011, 101101, 110110, 111000} is < 100011, 010101, 001110 > It follows that a generator matrix for this code is

1 0 0 0 1 1 G= 0 1 0 1 0 1 0 0 1 1 1 0

22

Latin Squares Artemis Toumazi

We can use the generator matrix to encode messages. Let a message m be a binary word of length k written as a row vector. The matrix product mG is a binary word of length n, which must be a codeword since mG is a sum of rows of G.

Example: Consider the (6, 8, 3) code {000000, 001110, 010101, 011011, 100011, 101101, 110110, 111000} This code has the 3 x 6 generator matrix

1 0 0 0 1 1 G= 0 1 0 1 0 1 0 0 1 1 1 0
A message m of length 3 can be encoded by evaluating the matrix product mG. Fr example, if m=110, then the codeword that corresponds to 110 is

1 0 0 0 1 1 1 1 0 0 1 0 1 0 1 = 1 1 0 1 1 0 0 0 1 1 1 0
Parity-Check Matrices
Consider the codeword of length n, transmitted on a noisy channel and received with some bits in error. We can think of the resulting word received as being the sum of the transmitted codeword and an error word(syndrome) of length n

(Received word) = (transmitted codeword) + (error code/syndrome) Linear codes have the following very useful property. To each (n,k) linear code there corresponds an (n-k) x n matrix H of 0s and 1s, with no row or column consisting entirely of 0s, and with the property that the code contains exactly those binary words x satisfying the matrix equation HxT=0T , where 0T is the column vector consisting of (n-k) zeros. We give this matrix H a special name.

23

Coding Theory

Definition 3.8 Let C be an (n,k) linear code. A Parity check matrix H is an (n-k) x n matrix with the property that the codewords of C are precisely the binary words x that satisfy the matrix equation HxT=0T.

Example: The linear code {0000, 0011, 1100, 1111} is a (4,2) code. The generator matrix G for this code is the 2x4 matrix

1 1 0 0 G= 1 1 1 1
The parity check matrix H for this code is the 2x4 matrix

We now show how the Parity check matrix of a code can be the key of decoding. Suppose that a codeword x from a code with the parity check matrix H is transmitted over a communication channel. Let e denote the error word that affects x, so that the word r=x+e is received. Then, HrT=H(x+e)T=H(xT+eT)=HxT+HeT=0T+HeT=HeT In other words, the column vector of length n-k that results from premultiplying the transpose of the received word by the parity check matrix is independent of the codeword transmitted. It depends only from ton the errors that have occurred. This column vector of length n-k is called the syndrome of the errors. Definition 3.9 For an (n,k) code with parity check matrix H, the error syndrome of a received word r is the column vector HrT of length n-k.

24

Latin Squares Artemis Toumazi

Example: The following matrix is a generator matrix for a (7, 16, 3) code.

G=

1 1 0 1

1 0 1 1

1 0 0 0

0 1 1 1

0 1 0 0

0 0 1 0

0 0 0 1

(a) Use the matrix G to encode the messages (1) 1011 (2) 0001 (b) Find the Parity-check matrix for this code (c) If we take the damaged codeword c = 0011100 find the error syndrome and use it to correct the codeword. (d) If we take the damaged codeword c = 0001100 find how many errors it has and check if it can correct. Answer: (a) For this section we evaluate the matrix product mG, where m is the given fourbit message. (1)

1 0 1 1
(2)

1 1 0 1 1 1 0 1

1 0 1 1 1 0 1 1

1 0 0 0 1 0 0 0

0 1 1 1 0 1 1 1

0 1 0 0 0 1 0 0

0 0 1 0 0 0 1 0

0 0 0 1 0 0 0 1

= 0 1 1 0 0 1 1 = 1 1 0 1 0 0 1

0 0 0 1

(b) The generator matrix is 4 x 7 matrix so the Parity-check matrix H is 3 x 7 matrix. Thus,

0 0 0 1 1 1 1 H= 1 1 0 0 1 1 0 0 1 1 0 0 1 1
25

Coding Theory

(c) Using the below diagram to find the error syndrome for the given damaged codeword c

Damaged Codeword c

Hc

Error Syndrome



Thus,

0 0 0 1 1 1 1 Hc = 1 1 0 0 1 1 0 0 1 1 0 0 1 1

0 0 1 1 1 0 0

0 = 1 1

Hence the error syndrome for the given c=0011100 is 011000, so there must be at least one error. If we assume that there is only one error, we can correct it as follows: Hc is the second column of parity-check matrix H, so the error is in the second digit. We correct the received codeword to 0111100, which is a codeword. (d) Using again the above diagram to find the error syndrome for the given damaged codeword c.

0 0 0 1 1 1 1 Hc = 1 1 0 0 1 1 0 0 1 1 0 0 1 1

0 0 0 1 1 0 0

0 = 1 0

26

Latin Squares Artemis Toumazi

Hence the error syndrome for the given c= 0001100 is 010000, so there must be at least one error. If we assume that there is only one error, we can correct it to 1001100 ( Hc is the first column of H then the error is in the first digit). This codeword is a codeword for this code so the message corrected. Therefore we correct the received codeword to 1001100, which is a codeword. Note that, the error syndrome 010 represents in the first column of H and also is the linear combination of 2nd column of H + 3rd column of H, so if the 2nd and 3rd bits are in error then we have the same error syndrome (i.e. 010)

Codes from Mutually Orthogonal Latin Squares (MOLSs)


Recall the definition of a q-ary code of length n is a subset C of An, where A is the set with q elements. The elements of C are called codewords. Therefore, for fixed q consider the problem of maximizing the number of codewords (denoted by M) in a q-ary code with the given length n and given minimum distance . To this end let Aq (n,) and then there exists an (n, M, ), q-ary code. Therefore we can construct (n, M, ) codes from MOLSs. Example: Consider the following pair of MOLS of order 3: 0 1 2 1 2 0 2 0 1 0 2 1 1 0 2 2 1 0

(Reference: Discrete Mathematics Using Latin Squares by Charles F. Laywine, Gary L.Mullen.) From these MOLS of order 3, a (4,9,3) code may be constructed. So the code has n=4, maximum number of codewords M=9 and minimum distance =3 ( Note that every pair of codewords differs in exactly 3 bits). To construct the code, first we build a 9x4 array whose first two columns are simply the coordinates of the 9 cells within a Latin Square of order 3. Remember that for convenience the 3 rows and columns of a 3x3 square are labeled as 0,1,2 rather than 1,2,3. Then we add the third column of the array by placing the symbols of the first Latin Square in sequence down the column of the array as we proceed from top to bottom across the rows of the given Latin Square. Similarly the fourth column of the array comes from the second Latin Square.
27

Coding Theory

This process yields the following array containing the 9 codewords of length 4 and minimum distance of =3: Row 0 0 0 1 1 1 2 2 2 Column 0 1 2 0 1 2 0 1 2 Square1 0 1 2 1 2 0 2 0 1 Square2 0 1 2 2 0 1 1 2 0

Give examples using MOLS of order 5 First we are using 1 5x5 Latin Square of order 5 : 0 1 2 3 4 1 2 3 4 0 2 3 4 0 1 3 4 0 1 2 4 0 1 2 3

With this one 5x5 Latin Square we can get a (3,25,2) code since each codeword has 3 bits which correspond to the row, the column and the symbol in the row column intersection, (i.e n=3) and the minimum distance , of any two codewords, is =2. We will construct a 25 codewords ( i.e M=52) We can see the 25 codewords of length 3 in the table 1.

28

Latin Squares Artemis Toumazi

(Table 1) 0 0 0 0 0 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4

Row 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4

Column

Square1 0 1 2 3 4 1 2 3 4 0 2 3 4 0 1 3 4 0 1 2 4 0 1 2 3

29

Coding Theory

Similarly a code using 2 mutually orthogonal, 5x5 Latin Squares, can be used to get a (4,25,3) code.

0 1 2 3 4

1 2 3 4 0

2 3 4 0 1

3 4 0 1 2

4 0 1 2 3

0 2 4 1 3

1 3 0 2 4

2 4 1 3 0

3 0 2 4 1

4 1 3 0 2

Here each codeword has 4 bits which correspond to the row, the column and the symbol in the row column intersection and the minimum distance =3.

A code using 3 mutually orthogonal, 5x5 Latin Squares, gives a (5,25,4) code. 0 1 2 3 4 1 2 3 4 0 2 3 4 0 1 3 4 0 1 2 4 0 1 2 3 0 2 4 1 3 1 3 0 2 4 2 4 1 3 0 3 0 2 4 1 4 1 3 0 2 0 3 1 4 2 1 4 2 0 3 2 0 3 1 4 3 1 4 2 0 4 2 0 3 1

Square 1

Square 2

Square 3

Here each codeword has 5 bits which correspond to the row, the column and the symbol in the row column intersection and minimum distance =4

30

Latin Squares Artemis Toumazi

And a code using the below 4 mutually orthogonal, 5x5 Latin Squares, used to get a (6,25,5) code. 0 1 2 3 4 1 2 3 4 0 2 3 4 0 1 3 4 0 1 2 4 0 1 2 3 0 2 4 1 3 1 3 0 2 4 2 4 1 3 0 3 0 2 4 1 4 1 3 0 2 0 3 1 4 2 1 4 2 0 3 2 0 3 1 4 3 1 4 2 0 4 2 0 3 1

0 4 3 2 1

1 0 4 3 2

2 1 0 4 3

3 2 1 0 4

4 3 2 1 0

Here each codeword has 6 bits which correspond to the row, the column and the symbol in the row column intersection and minimum distance =5.

In Chapter 2 we obtained a set of 3 mutually orthogonal 4x4 Latin Squares. One square can be used to construct a (3,16,4) code, 2 squares can used to construct a (4,16,4) code and all 3 mutually orthogonal Latin Squares can be used to construct a (5,16,4) code. In the final code, each codeword has 5 bits which correspond to the row, the column and the three symbols in the row column intersection and minimum distance =4.

31

Latin Squares Artemis Toumazi

4 Comparison of code performance


The English Language contains 26 letters. Some of those, such as x, are not used very frequently. We can therefore encode text using 25 codewords to represent letters & space with 2 codewords doubling up to each represent 2 symbols. A suitable code is a (5, 25, 4) code using the 3 MOLS of order 5 given on page 30. The following array contains 25 codewords of length 5 and minimum distance =4 (Note that every pair of codewords differs in exactly 4 bits) : Row 0 0 0 0 0 1 1 1 1 1 2 2 2 2 2

Col 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4

Sq1 0 1 2 3 4 1 2 3 4 0 2 3 4 0 1

Sq2 0 1 2 3 4 2 3 4 0 1 4 0 1 2 3

Sq3 0 1 2 3 4 3 4 0 1 2 1 2 3 4 0
32

Comparison of code performance

Row 3 3 3 3 3 4 4 4 4 4 0 1 2 3 4 0 1 2 3 4

Col

Sq1 3 4 0 1 2 4 0 1 2 3 1

Sq2

Sq3 4 0 1 2 3 2 3 4 0 1

2 3 4 0 3 4 0 1 2

Each row of the (5, 25, 4) code is used to represent one letter from the English alphabet. For example the first row, of the matrix of the code, represents the letter A, the second row represents the letter B, etc. Note that, there are 25 codewords and the English alphabet has 26 letters so we have to use one codeword to represent two different letters, say Y & Z and also another codeword to represent the space and the apostrophe. (see the table 1) Then we have the below table 1, which represents the encoded message for each letter of the English alphabet, space and apostrophe .

33

Latin Squares Artemis Toumazi

Example: Use the code to encode the phrase circle. The encoded message for the circle is 02222 13401 32031 02222 21302 04444. (where c=02222, i=13401, r=32031, l=21302 and e=04444) Use also this code to encode the mathematical phrase Euler's formula starting with the geometric properties . The encoded message for this sentence is 04444 40432 21302 04444 32031 42104 33142 43210 10123 24130 32031 22413 40432 21302 00000 43210 33142 34203 00000 32031 34203 13401 23024 11234 43210 42104 13401 34203 12340 43210 34203 12340 04444 43210 11234 04444 24130 22413 04444 34203 32031 13401 02222 43210 30314 32031 24130 30314 04444 32031 34203 13401 04444 33142 Use also this code to encode the phrase: Don't spoil circles. The encoded message is: 03333 24130 23024 42104 34203 43210 33142 30314 24130 13401 21302 43210 02222 13401 32031 02222 21302 04444 33142.

Letter A B C D E F G H I J K L M N O P Q R S T U V W& (Table 1) X & space Y&Z

Encoded message 00000 01111 02222 03333 04444 10123 11234 12340 13401 14012 20241 21302 22413 23024 24130 30314 31420 32031 33142 34203 40432 41043 42104 43210 44321
34

Comparison of code performance

It will be interesting to compare the performance of the code based on Latin Squares with a binary code. 24=16 & 25 =32, since the English alphabet has 25 letters this suggests that a code with 32 codewords is appropriate. Example: Find a Binary Code with 32 codewords and use this to encode the mathematical sentence Euler's formula starting with the geometric properties . Solution: The Binary Code (q=2) with 32 (i.e 25 ) codewords means that we must have 5 rows in a generator matrix G. Therefore we need a (n, M, ) = (5, 32, ) code. I will start by using a code of smallest possible length, namely 5 with generator matrix: Table 2

G=

1 0 0 0 0

0 1 0 0 0

0 0 1 0 0

0 0 0 1 0

0 0 0 0 1

00000 10011 01101 11110 10000 00011

00010 10001 01111 11100 00001 10010 01100 11111 11000 01011 10101 00110 10100 00111 11001 01010
35

From the generator matrix the smallest distance is =1 so G yields a (5,32,1) code.

11101 01110 01000

The 32 codewords generated by G are contained in table 2.

11011 00101 10110 00100 10111 01001 11010

Latin Squares Artemis Toumazi

I will use the first codeword to represent the letter A, the second codeword to represent the letter B, etc. Note that, there are 32 codewords but only 26 letters in the English alphabet so some of codewords are not used to represent any letter. This gives table 3, which indicates the encoded message for each letter of the English alphabet. As with the Latin Square code, I will use the binary code to encode the mathematical phrases Circle and Euler's formula starting with the geometric properties and Don't spoil circles. Table 3 The encoded message for the word Circle is 01101 01000 10001 01101 10110 10000 The encoded message for the phrase Euler's formula starting with the geometric properties is: 10000 00001 10110 10000 10001 00110 01111 10101 00011 01001 10001 00100 00001 10110 00000 10101 01111 11100 00000 10001 11100 01000 01000 10111 11101 10101 01100 01000 11100 01110 10101 11100 01110 10000 10101 11101 10000 01001 00100 10000 11100 10001 01000 01101 10101 11010 10001 01001 11010 10000 10001 11100 01000 10000 01111. The encoded message for the phrase Don't spoil circles is: 11110 01001 10111 00110 11100 10101 01111 11010 01001 01000 10110 10101 01101 01000 10001 01101 10110 10000 01111. Letter A B C D E F G H I J K L M N O P Encoded message 00000 10011 01101 11110 10000 00011 11101 01110 01000 11011 00101 10110 00100 10111 01001 11010 Letter Q R S T U V W X Y Z Space Encoded message 00010 10001 01111 11100 00001 10010 01100 11111 11000 01011 10101 00110 10100 00111 11001 01010

36

Comparison of code performance

Having obtained the 2 codes, I will now simulate errors in the received messages in order to compare the performances of the codes. Start by generating random sequences to select transmission bits that will contain errors.

Generation of Random Sequences

I would like approximately 10% of transmitted bits to contain errors. To achieve this generate a random sequence of say 100 0s and 1s so that the probability of a 0 is 90% and of a 1 is 10%. The following commands are used in Matlab:

> p= 0.90 p = 0.9000 > (rand(1,100)<=(1-p)) ans = 00000 00000 01000 00010 00000 00100

% take a probability p=90%=0.90.

% take a random sequence of which 1 has probability 1-p=10% and 0 has probability p=90%.

10000 00000 00000

00000 10000 01100

01000 00000 00011

01000 00000 00010

00000

00000

For a sample of 150 we take: > (rand(1,150)<=(1-p)) % take a random sequence of which 1 has probability 1-p=10% and 0 has probability p=90%

000000000001000000100010001000000000000000001000001000000000 00010000100011000000000000001000000000000000000000000000000000000 000000000000001001000000 This can be adapted to obtain a sequence of randomly generated 0s and 1s of any length where p is the probability of a 0 and 1-p is the probability of a 1. The 1s in the sequence can be used to identify transmitted bits in a binary code in which there is an error. To simulate errors in the Latin Square code a more sophisticated random sequence is required.

37

Latin Squares Artemis Toumazi

Generate a random sequence of 100 0s, 1s, 2s, 3s and 4s so that the probability of a 0 is 90%, of 1 is 2.5%, of a 2 is 2.5%, of a 3 is 2.5% and of 4 is 2.5%. The commands are similar to those used in the binary code but the sequence does not only involve 0s and 1s but also 2s, 3s and 4s. The following commands are used in Matlab: > R = randsample('01234',100, true ,[0.9 0.025 0.025 0.025 0.025]) % find the random sequence of 100 0s, 1s, 2s, 3s and 4s with probability of 0 is 90%, of 1 is 2.5%, of 2 is 2.5%, of 3 is 2.5% and of 4 is also 2.5%. R = 21000 20000 00000 40000 00003 00030 00000 00000 00000 00000 00000 00303 00000 00003 00000 00000 00200 00000 00000 00000

Note: In both cases the sequence obtained is random and each time we put the
commands in Matlab we obtain a different result. In practice errors occur when messages are transmitted. We will use the random sequences to simulate errors. We will then try to identify and correct any errors and we will compare the performances of the 2 codes. Take the first random sequence and use it to insert errors in the encoded messages from the binary code, of the phrases Circle and Don't spoil my circles. This is done in the tables below. Bits whose positions correspond to 1s in the random sequence are selected to be received incorrectly. First for the phrase: circle random sequence 1 2 3 4 5

encoded message 0 1 1 0 1

corrupted message 0 1 1 0 1

Received message

0 0 0 0 0

38

Comparison of code performance

random sequence 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

encoded message 0 1 0 0 0 1 0 0 0 1 0 1 1 0 1 1 0 1 1 0 1 0 0 0 0

corrupted message 0 1 0 1 0 0 0 0 0 1 0 1 1 0 1 1 1 1 1 0 1 1 0 0 0

Received message
There are two codewords that differ in 2 bits from 01010

0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0

P or Z

39

Latin Squares Artemis Toumazi

The corrupted message is: C- P/Z - U - C - D - Y Comment: It is not possible to identify that the transmitted message was circle.

Secondly we do it for the phrase Don't spoil circles random sequence 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19


encoded message 1 1 1 1 0 0 1 0 0 1 1 0 1 1 1 0 0 1 1

corrupted message 1 1 1 1 0 0 1 0 1 1 0 0 1 1 1 0 0 1 1

Received message

0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0

40

Comparison of code performance

random sequence 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

encoded message 0 1 1 1 0 0 1 0 1 0 1 0 1 1 1 1 1 1 0 1 0 0 1 0 0

corrupted message 0 1 0 1 0 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 0 0 1 0 0

Received message

0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

41

Latin Squares Artemis Toumazi

random sequence 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69

encoded message 1 0 1 0 0 0 1 0 1 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 0

corrupted message 1 1 1 0 0 0 1 0 1 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 0

Received message

0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Space

42

Comparison of code performance

random sequence 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94

encoded message 0 1 0 0 0 1 0 1 1 0 1 1 0 1 1 0 1 0 0 0 0 0 1 1 1

corrupted message 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 1 1 1 0 0 0 1 1 0

Received message

0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1

43

Latin Squares Artemis Toumazi

random sequence 95 1 1

encoded message

corrupted message 0

Received message

The corrupted message is: D, Z, -, , -, G, S, P, O, Y, L, SPACE, C, I, -, O, L, T, W. Comment: Again we see that it is not possible to identify that the transmitted message was the phrase Don't spoil circles .

Example: Use the second random sequence to generate errors in the transmitted message using the Latin Square (5,25,4) code and find the corrupted message for the encoded message for the phrases circle and Don't spoil circles . Bits whose positions correspond to 1s, 2s, 3s or 4s in the random sequence are selected to be received incorrectly. To simulate the error, a bit corresponding to i for i=0,1,2,3,4 in the random sequence has i added to it in the transmitted sequence-arithmetic modulo 5. This is done in the tables below: random sequence 1 2 3 4 5 6 7 8 9 10 11

encoded message 0 2 2 2 2 1 3 4 0 1 3

corrupted message 2 3 2 2 2 3 3 4 0 1 3
44

2 1 0 0 0 2 0 0 0 0 0

There are two codewords that differ in 2 bits from 23222 There are two codewords that differ in 2 bits from 33401

C or N

S or I

Comparison of code performance

random sequence 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 0 0 0 0 4 0 0 0 0 0 0 0 0 3 0 0 0 3 0

encoded message 2 0 3 1 0 2 2 2 2 2 1 3 0 2 0 4 4 4 4

corrupted message 2 0 3 1 4 2 2 2 2 2 1 3 0 3 0 4 4 0 4 E L C R

Therefore the corrupted message is: C (or N) - I (or S) - R - C - L - E Comment: It is easier to guess what the transmitted message was(i.e. circle.)

45

Latin Squares Artemis Toumazi

Do it the same for the phrase Don't spoil circles . random sequence 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

encoded message 0 3 3 3 3 2 4 1 3 0 2 3 0 2 4 4 2 1 0 4 3 4 2 0

corrupted message 2 4 3 3 3 4 4 1 3 0 2 3 0 2 4 4 2 1 0 4 3 4 2 0
46

2 1 0 0 0 2 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0

There are two codewords that differ in 2 bits from 24333

D or O

Comparison of code performance

random sequence 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 3 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

encoded message 3 4 3 2 1 0 3 3 1 4 2 3 0 3 1 4 2 4 1 3 0 1 3 4 0

corrupted message 3 4 3 2 4 0 3 3 1 4 2 3 0 3 1 4 2 4 1 3 0 1 3 4 0 I O P S X & Space


There are two codewords that differ in 2 bits from 43240

47

Latin Squares Artemis Toumazi

random sequence 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 0 0 0 0 0 0 0 0 3 0 3 0 0 0 0 0 0 0 0 0 3 0 0 0 0

encoded message 1 2 1 3 0 2 4 3 2 1 0 0 2 2 2 2 1 3 4 0 1 3 2 0 3

corrupted message 1 2 1 3 0 2 4 3 0 1 3 0 2 2 2 2 1 3 4 0 4 3 2 0 3 R I C X & Space


There are two codewords that differ in 2 bits from 43013

48

Comparison of code performance

random sequence 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0

encoded message 1 0 2 2 2 2 2 1 3 0 2 0 4 4 4 4 3 3 1 4 2

corrupted message 1 0 2 2 2 2 2 1 0 0 2 0 4 4 4 4 3 3 1 4 2 S E L C

The corrupted message is: D/O o n t s p o i l / c i r c l e s Comment: It is easier to guess what the transmitted message was(i.e. Dont spoil circles)

49

Latin Squares Artemis Toumazi

It is not surprising that the binary code demonstrated poor performance since was only 1. I will obtain another binary code which is better in that it will have a value of which is >1. This will enable errors to be identified. Example: Find a Binary code with 32 codewords and use this to encode the mathematical word ORTHOGONAL .

Solution:

The Binary code(q=2) with 32 (i.e 25 ) codewords means that we must have 5 rows in a generator matrix G. Therefore we need a (n, M, ) = (5, 32, >1) code. Use the generator matrix G,



0 0 0 0 1 1 1 1 0 0 0 0 0 1 1
0000000 1001101 0110101 1111011 1000010 0001100 1110111 0111001 0100010 1101100 0010111 1011001 0010010 1011100 0100111 1101001

Table 1 0001001 1000111 0111100 1110010 0000101 1001011 0110000 1111110 1100000 0101110 1010101 0011011 1010000 0011110 1100100 0101011

G=

1 0 0 0 0

0 1 0 0 0

0 0 1 0 0

0 0 0 1 0

Here the last two columns are used to generate check bits. The first check bit column can be found by adding the first column + 2nd column + 3rd column (mod 2) and the 2nd check bit column can be found by adding the 4th column and the 5th column of the Generator matrix. From the Generator matrix the smallest distance is =2 since, if we take any two codewords from the G we see that the smallest distance is 2, and n=7. The smallest distance =2 means that we can detect if 1 error has occurred in a received word during the transmission process but we cant necessarily correct the error because the corrupted word may be a distance of exactly 1 bit from 2 different words. For example, if we have the encoded message 1000010 istransmitted but is received as 1000011.

50

Comparison of code performance

Therefore to encode some words as in the previous examples we have to use a (7, 32, 2) code. The 32 codewords of the code are included in table 1. Letter A B C D E F Table 2, gives the encoded message for each letter of the English alphabet. G H I J The encoded message for the word ORTHOGONAL is 0100111 1000111 1110010 0111001 0100111 1110111 0100111 1011100 0000000 1011001 (table 2) K L M N O P Encoded message 0000000 1001101 0110101 1111011 1000010 0001100 1110111 0111001 0100010 1101100 0010111 1011001 0010010 1011100 0100111 1101001 Letter Q R S T U V W X Y Z Space Encoded message 0001001 1000111 0111100 1110010 0000101 1001011 0110000 1111110 1100000 0101110 1010101 0011011 1010000 0011110 1100100 0101011

Use the above code to encode the mathematical word ORTHOGONAL As before, assign each letter of the alphabet to a codeword.

As before, I use the random sequence to simulate errors in the message and obtain a corrupted message for the word ORTHOGONAL.

51

Latin Squares Artemis Toumazi

random sequence 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

encoded message 0 1 0 0 1 1 1 1 0 0 0 1 1 1 1 1 1 0 0 1 0 0 1 1

corrupted message 0 1 0 0 1 1 1 1 1 0 1 1 1 1 1 1 1 0 0 1 0 1 1 1
52

0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0

There are two codewords

R or O

that differ in 2 bits from 1000111

Comparison of code performance

random sequence 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

encoded message 1 0 0 1 0 1 0 0 1 1 1 1 1 1 0 1 1 1 0 1 0 0 1 1 1

corrupted message 1 0 1 1 0 1 0 0 1 1 1 1 1 1 0 1 1 1 0 1 0 1 1 1 1
53

There are

0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0

H or X

two codewords that differ in 2 bits from 0111001

There are two codewords that differ in 2 bits from 0100111

O or Z

Latin Squares Artemis Toumazi

random sequence 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

encoded message 1 0 1 1 1 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 1

corrupted message 1 0 1 1 1 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 1 L A N

The corrupted message is: O-R/O-T-H/X-O-G-O/Z-N-A-L Comment: It is easier to decipher the original message using this Binary Code than it was from the previous Binary Code.
54

Comparison of code performance

Since =2, there are some limitations of the code-errors can be detected but not corrected with certainly. The advantage of a Binary Code with 3 is that if exactly 1 error has occurred in a word during transmission then it can be corrected. Example: Find a Binary Code with =3 and with 32 codewords and use this to encode the mathematical word PERPENDICULAR . Solution: The Binary Code(q=2) with 32 (i.e 25 ) codewords means that we must have 5 rows in a generator matrix G. Let assume that the generator matrix of the code is: Table 1 000000000 100111100 011011010 111100110 100001001 000110101 111010011 011101111 010001101 110110001 001010111 From the generator matrix the smallest distance is =3 since if we take 2 codewords we see that they are at least differ in 3 bits (i.e. if x=100001001 and y=010001101 we see that d(x,y)=3 and is the smallest one between other codeword so =3) and has length n=9. 101101011 001000100 101111000 010011110 The 32 codewords of the code are included in table 1. 110100010 000100110 100011010 011111100 111000000 000010011 100101111 011001001 111110101 110000100 010111000 101011110 001100010 101001101 001110001 110010111 010101011

G=

1 0 0 0 0

0 1 0 0 0

0 0 1 0 0

0 0 0 1 0

0 0 0 0 1

1 1 0 0 0

0 1 1 1 0

0 0 0 1 1

1 1 0 0 1

55

Latin Squares Artemis Toumazi

The code with =3 is used to encode the mathematical word PERPENDICULAR As before, assign each letter of the alphabet to a codeword.

Table 2, gives the encoded message for each letter of the English alphabet. The encoded message for the word PERPENDICULAR is 110100010 100001001 100011010 110100010 100001001 101111000 111100110 010001101 011011010 000010011 101101011 000000000 100011010.

Letter A B C D E F G H I J K L M N O

Encoded message 000000000 100111100 011011010 111100110 100001001 000110101 111010011 011101111 010001101 110110001 001010111 101101011 001000100 101111000 010011110 110100010

Letter Q R S T U V W X Y Z Space -

Encoded message 000100110 100011010 011111100 111000000 000010011 100101111 011001001 111110101 110000100 010111000 101011110 001100010 101001101 001110001 110010111 010101011

(Table 2)

56

Comparison of code performance

As before, I use the random sequence to simulate errors in the message and obtain a corrupted message for the word PERPENDICULAR random sequence 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

encoded message 1 1 0 1 0 0 0 1 0 1 0 0 0 0 1 0 0 1 1 0 0 0 1 1 1 0 1 0 0 0 1 0 1 0 1 0 0 1 0 0 1 0 0 0 0 0

corrupted message

received message

0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 1

There are two codewords that differ in 2 bits from 100001001

E or L

There are three codewords

R or V or I

that differ in 3 bits from

57

100011010

Latin Squares Artemis Toumazi

random sequence 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

encoded message 1 0 1 0 1 1 0 1 0 0 0 1 0 1 0 0 0 0 1 0 0 1 1 0 1 0 1 1 1 1 0 1 0 0 0 1 0 1 0 0 0 0 1 0 0 1 0 0

corrupted message

received message

0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0

58

Comparison of code performance

random sequence 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

encoded message 1 1 1 1 0 0 0 1 1 1 1 0 0 1 1 0 0 1 0 0 0 1 1 0 1 1 1 1 1 0 0 1 1 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0

corrupted message

received message

0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0

There are two codewords that differ in 2 bits from 101111000

N or B

There are two codewords

I or A

that differ in 2 bits from 010001101

59

Latin Squares Artemis Toumazi

random sequence 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95

encoded message 1 0 1 1 0 1 1 0 1 0 0 0 0 0 1 0 0 1 1 1 0 1 1 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0 1 1 0

corrupted message

received message

0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0

There are two codewords

C or U

that differ in 2 bits from 011011010

60

Comparison of code performance

random sequence 96 0 1 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 1 0

encoded message 1 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 1 0

corrupted message

received message

100 0 101 0 102 0 103 0 104 0 105 0 106 0 107 0 108 0 109 0 110 0 111 0

112 0 113 0 114 0 115 0 116 0 117 0 118 0 119 0 120 0

The corrupted message is: P- E/L - R/V/I - P - E - N/B - D - I/A - C/U - U - L - A - R


61

Latin Squares Artemis Toumazi

Comment: Its not easier to guess what the transmitted message was. Conclusion: The performance of the codes obtained from MOLS was consistently better than the performance of the Binary Codes even, for Binary Codes including as many as, 3 check bits. Example: Compare the performance of a code from 2 non-orthogonal Latin Squares, of order 4, with a code from two orthogonal Latin Squares of order 4. I will use the two non-orthogonal Latin Squares of order 4 which are given on page 16 and the two orthogonal Latin Squares of order 4 which are used on the bottom of page 18. These give Tables 1 & 2. Table 1 Table 2 (non-orthogonal squares) (orthogonal squares) Row 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3

Column 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3

Square1 0 1 2 3 1 2 3 0 2 3 0 1 3 0 1 2

Square2 0 1 2 3 3 0 1 2 2 3 0 1 1 2 3 0 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3

Row

Column 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3

Square1 0 1 2 3 1 0 3 2 2 3 0 1 3 2 1 0
62

Square2 0 1 2 3 2 3 0 1 3 2 1 0 1 0 3 2

Comparison of code performance

Using the same approach as in previous examples we have to use a (4,16,2) code for non-orthogonal squares and a (4,16,3) code for orthogonal squares. Assign each letter of the alphabet to a codeword. Tables 3 & 4 give the encoded message for each letter of the English alphabet using first two non-orthogonal Latin Squares and after two orthogonal. Table 3 Letter A,Space B,M,O C D E F,Y G H,X,Q I P J,K,Z L N R U S,T,V,W Encoded message 0000 0111 0222 0333 1013 1120 1231 1302 2022 2133 2200 2311 3031 3102 3213 3320 Letter A,Space B,M,O C D E F,Y G H,X,Q I P J,K,Z L N R U S,T,V,W Table 4 Encoded message 0000 0111 0222 0333 1012 1103 1230 1321 2023 2132 2201 2310 3031 3120 3213 3302

According to table 3, the encoded message for the word PERPENDICULAR is: 2133 1013 3102 2133 1013 3031 0333 2022 0222 3213 2311 0000 3102.

63

Latin Squares Artemis Toumazi

According to the table 4, the encoded message for the word PERPENDICULAR is: 2132 1012 3120 2132 1012 3031 0333 2023 0222 3213 2310 0000 3120 We use the random sequence in each time to simulate errors in the message. For the two non-orthogonal Latin Squares we obtain the corrupted message: C/P/U - E/U - R - P - E - N - D - I - C - U - L - A - R. The corrupted message for the orthogonal squares is: C/G/P- E - R - P - E - N - D - I - C - U - L - A - R We realize that the performance of the code from two orthogonal Latin Squares is better that the code from two non-orthogonal Latin Squares.

64

References
I. Latin Squares and their applications by J.Dnes and A.D.Keedwell, Academic Press, New York, 1974 The worlds of David Darling, encyclopedia of science

II.

III. Wikipedia encyclopedia http://en.wikipedia.org IV. http://www.unom.ac.in/Gautham_mols.pdf V. Nrich, http://nrich.maths.org VI. Discrete Mathematics Using Latin Squares by Charles F.Laywine,Gary L.Mullen. VII. Latin Squares: New Developments in the Theory and Applications by J.Dnes, A.D.Keedwell. VIII. Google Images : http://www.google.com IX. http://math.ucdenver.edu/~wcherowi/courses/m6406/csln3.html

X. Linear Algebra: A modern Introduction, Second Edition by David Poole XI. The Open University, MT 365 Graphs, networks and design Design 3, Design of codes. XII. Module MAT2005, Algebra And Codes by David Fisher, University of Surrey, 2010-2011.

65