Smart Codes UCLA Math Circle 09/30/2012

Similar documents
Cyber Security Workshop Encryption Reference Manual

Grade 6 Math Circles. Binary and Beyond

Check Digits for Detecting Recording Errors in Horticultural Research: Theory and Examples

Section 1.4 Place Value Systems of Numeration in Other Bases

= = 3 4, Now assume that P (k) is true for some fixed k 2. This means that

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

1. Define: (a) Variable, (b) Constant, (c) Type, (d) Enumerated Type, (e) Identifier.

Colored Hats and Logic Puzzles

Pigeonhole Principle Solutions

Session 7 Fractions and Decimals

Base Conversion written by Cathy Saxton

3 Some Integer Functions

Number Theory. Proof. Suppose otherwise. Then there would be a finite number n of primes, which we may

Introduction to Algebraic Coding Theory

The string of digits in the binary number system represents the quantity

Chapter 11 Number Theory

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

Linear Codes. Chapter Basics

Math Workshop October 2010 Fractions and Repeating Decimals

2 Number Systems. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

Encoding Text with a Small Alphabet

Math Circle Beginners Group October 18, 2015

Chapter 3. if 2 a i then location: = i. Page 40

Welcome to Basic Math Skills!

Patterns in Pascal s Triangle

HOMEWORK # 2 SOLUTIO

=

Primes. Name Period Number Theory

If A is divided by B the result is 2/3. If B is divided by C the result is 4/7. What is the result if A is divided by C?

Information Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay

Multiplication and Division with Rational Numbers

Binary Adders: Half Adders and Full Adders

Kenken For Teachers. Tom Davis June 27, Abstract

Advanced Cryptography

To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

NUMBER SYSTEMS. 1.1 Introduction

Class Notes CS Creating and Using a Huffman Code. Ref: Weiss, page 433

NUMBER SYSTEMS. William Stallings

CONTENTS. Please note:

Reading 13 : Finite State Automata and Regular Expressions

We can express this in decimal notation (in contrast to the underline notation we have been using) as follows: b + 90c = c + 10b

MACM 101 Discrete Mathematics I

Solution for Homework 2

Identification Numbers and Check Digits 1

6 EXTENDING ALGEBRA. 6.0 Introduction. 6.1 The cubic equation. Objectives

CS101 Lecture 11: Number Systems and Binary Numbers. Aaron Stevens 14 February 2011

Levent EREN A-306 Office Phone: INTRODUCTION TO DIGITAL LOGIC

FTS Real Time Client: Equity Portfolio Rebalancer

Chapter 4: Computer Codes

Third Southern African Regional ACM Collegiate Programming Competition. Sponsored by IBM. Problem Set

Quick Reference ebook

1 Solving LPs: The Simplex Algorithm of George Dantzig

Activity 1: Using base ten blocks to model operations on decimals

Notes 11: List Decoding Folded Reed-Solomon Codes

This lesson can be adapted to the grade level by the presenter. Decide the level of content and activities as appropriate.

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

Math 319 Problem Set #3 Solution 21 February 2002

Unit 1 Number Sense. In this unit, students will study repeating decimals, percents, fractions, decimals, and proportions.

College of information technology Department of software

Solution to Exercise 2.2. Both m and n are divisible by d, som = dk and n = dk. Thus m ± n = dk ± dk = d(k ± k ),som + n and m n are divisible by d.

The application of prime numbers to RSA encryption

EE6-5 Solving Equations with Balances Pages 77 78

Number Systems and Radix Conversion

OA3-10 Patterns in Addition Tables

Task: ASC Ascending Paths

Unit 7 The Number System: Multiplying and Dividing Integers

Chapter 23. Database Security. Security Issues. Database Security

Seriously Simple Sums! Vedic Maths Free Tutorial. Maths Tips and Tricks to Improve Your Math Abilities

MATHEMATICS. Y5 Multiplication and Division 5330 Square numbers, prime numbers, factors and multiples. Equipment. MathSphere

LAMC Beginners Circle: Parity of a Permutation Problems from Handout by Oleg Gleizer Solutions by James Newton

MII stands for major industry identifier; 4 and 5 indicate Banking and Financial. VISA cards begin with 4 and MasterCard cards with 5.

2.5 Zeros of a Polynomial Functions

Homework until Test #2

Ummmm! Definitely interested. She took the pen and pad out of my hand and constructed a third one for herself:

Binary Number System. 16. Binary Numbers. Base 10 digits: Base 2 digits: 0 1

INTERSECTION MATH And more! James Tanton

Number of bits needed to address hosts 8

mod 10 = mod 10 = 49 mod 10 = 9.

Math 55: Discrete Mathematics

MATHS ACTIVITIES FOR REGISTRATION TIME

V Quantitative Reasoning: Computers, Number Theory and Cryptography

Chapter 3. Distribution Problems. 3.1 The idea of a distribution The twenty-fold way

Permutation Groups. Tom Davis April 2, 2003

N O T E S. A Reed Solomon Code Magic Trick. The magic trick T O D D D. M A T E E R

PURSUITS IN MATHEMATICS often produce elementary functions as solutions that need to be

Computer Networks. Network Security 1. Professor Richard Harris School of Engineering and Advanced Technology

43 Perimeter and Area

Unit 6 Number and Operations in Base Ten: Decimals

2x + y = 3. Since the second equation is precisely the same as the first equation, it is enough to find x and y satisfying the system

CSI 333 Lecture 1 Number Systems

The Pointless Machine and Escape of the Clones

6 The Hindu-Arabic System (800 BC)

Basics of Counting. The product rule. Product rule example. 22C:19, Chapter 6 Hantao Zhang. Sample question. Total is 18 * 325 = 5850

1 Math Circle WARM UP

Actually Doing It! 6. Prove that the regular unit cube (say 1cm=unit) of sufficiently high dimension can fit inside it the whole city of New York.

Hill s Cipher: Linear Algebra in Cryptography

Creating a Gradebook in Excel

The Mathematics of the RSA Public-Key Cryptosystem

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Positional Numbering System

Transcription:

Smart Codes UCLA Math Circle 09/30/2012 1 Error Detection Sequences of numbers, or codes, are ubiquitous in our lives. Some of them, such as credit card number and bank account numbers, are very important. They are also very sensitive to man-made and mechanical errors. So it is important that some of these numbers have the ability to detect, and even correct possible errors. A nice example of codes with the ability to detect errors is the ISBN, a number associated to every book. There are two versions: one with 10 digits, one with 13 digits. For example, the 10-digit ISBN the first Twilight novel is 0316160172. The first digit 0 tells us that the book is in English. The next eight digits contains the publishing information of the book, and the last digit is used to to check that this is a valid ISBN number. Suppose the first 9 numbers in a sequence of 10 digits looks like Calculate the following sum modulo 11 a 1 a 2 a 9. 9 k a k, (1) k=1 i.e. find its remainder when it is divided by 11. The sequence is a valid ISBN number if and only if the remainder agrees with the last digit, where we use the digit X to represent the remainder 10. In the Twilight example above, we have a 1 a 2 a 9 = 031616017. The number in the expression (1) is 9 k a k = 1 0 + 2 3 + 3 1 + 4 6 + 5 1 + 6 6 + 7 0 + 8 1 + 9 7 (2) k=1 = 145 2 (mod 11). (3) 1

Since the remainder agrees the last digit 2, this is a valid ISBN number. Exercise 1. Calculate the sum (1) for the following sequences of numbers to see if it could be a valid ISBN number. (a) 0439023521 (b) 311001436X (c) 0439784542 Exercise 2. Given a sequence a 1 a 2... a 10, consider the sum 10 a 1 + 9 a 2 + + 2 a 9 + a 10. (4) What is its remainder when divided by 11 if a 1 a 2... a 10 is the number in Exercise 1(a), 1(b), 1(c) respectively. Exercise 3. Show that a sequence a 1 a 2... a 10 could be a valid ISBN number if the sum in (4) divisible by 11. Exercise 4. In Exercise 1, is it possible to change a single digit in a valid ISBN number such that it is still valid? Vice versa, is it possible to make an invalid ISBN number into a valid ISBN number? What about swapping two adjacent digits? Besides the 10-digit ISBN number, the 13-digit ISBN number is also in use. For example, the 13-digit ISBN of the fourth Harry Potter book is 9780439139601, compare to the 10-digit ISBN number 0439139600. The first three digits of the 13-digit ISBN number provide more information about the book, and the last digit is still used for an error-detection. However, its error-detection mechanism is different from the one we described above. Given a sequence of twelve digits between 0 and 9, say a 1 a 2... a 11 a 12, we need to consider the following sum modulo 10 12 k=1 (2 + ( 1) k )a k = a 1 + 3 a 2 + a 3 + 3 a 4 + + a 11 + 3 a 12. (5) It needs to agree with the last digit for a 1 a 2... a 11 a 12 to be a valid 13-digit ISBN number. 2

Exercise 5. Check whether the following sequence is a valid 13-digit ISBN number (a) 9780439139601 (b) 9780439784542 (c) 9781178050233 (d) 9783110014635 Exercise 6. Try Exercise 4 for 13-digit ISBN numbers. Compare the results with those of Exercise 4. Exercise 7. For the 13-digit ISBN number, modify the error-detection mechanism, as best as you could, so that it can detect transposition of neighboring digits, in addition to detecting other simple errors. 2 Error Correction From the exercises above, we see that both the 10-digit and 13-digit ISBN numbers can detect single digit error. However, it cannot correct the error automatically upon discovering it, since any digit could be the one with error. In fact, early computers do not have such capability and would stop if it runs into an error while reading codes. This was an annoying problem and people tried to create smarter codes that could correct simple errors. For simplicity, we only use the digits, or bits, 0 and 1 in a string from now on. Also, we assume all codewords in a code have the same length. The simplest idea is to repeat each bit several times. For example, if we have the digits 1010110 and encode it by repeating each digit 3 times, then we have the codeword 111000111000111111000 Suppose we see 111000110100111111000 instead, then we can immediately fix the error and recover the original string of digits 1010110 Not only does this method detect the existence of single digit and transposition errors, but also their locations and hence fix them. Suppose we fix an integer k to be the length of the string and r the number of times a digit is to be repeated Then the total length of the codeword is n = k r. All such possible 3

codewords together is called a repeating [n, k]-code. For example, a repeating [4, 2]-code contains the codewords 0000, 0011, 1100 and 1111. To measure the efficiency of codes, we can use the quantity information rate defined by R = log 2(w), (6) n where w is the total number of codewords in the code, and n is the length of each codeword. For example, the information rate of the repeating [4, 2]-code is log 2 (4) 4 = 1 2. Exercise 8. Write down all the codewords in a repeating [6, 2]-code and calculate its information rate. Exercise 9. What is the information rate of a repeating [n, k]-code? Can it correct singledigit error? An example of a more complicated coding scheme is Hamming s square code. Begin with a message with 4 bits. First, write this message in a 2 2 square. Then compute the sum of each row, respectively each column, and write it at the end of the row, respectively the bottom of the column. Finally compute the sum of all entries and write it in the lower right corner to complete a 3 3 square. Reading out the 9 bits then gives the codeword. Since we only have 0 s and 1 s in the alphabet, the addition rules will be 0 + 0 = 0, 1 + 0 = 1, 1 + 1 = 0. For example, if the message is 1011, then the codeword is 101110011. 1011 1 0 1 0 1 1 1 1 1 0 0 1 1 0 1 1 1 0 0 1 1 101110011 Exercise 10. The following codewords are encoded using the method above. Correct any single-digit or transposition error if there is any. (a) 110110011 (b) 100101011 4

(c) 001010110 Exercise 11. If a single-digit errors is present in the codeword, can it be discovered and fixed? What about a transposition? Exercise 12. Show that the information rate of Hamming s 2 2 square code is 4 9. Generalize this coding method to m n rectangular code and find its information rate. If m n is fixed, when is the information rate maximum? Compare it to the maximal information rate of the repeating code. Exercise 13. Is the m n rectangular code capable of correcting single-digit errors or transposition errors? Exercise 14. If the last digit in the codeword is removed, can we still decode the message? What about fixing single-digit error or transposition error? What is the information rate? From Exercise 12, we know that the m n rectangular code is much more efficient at encoding information than the simple repeating code. In fact, the information rate increases as the length of the message increases. For message word with 4-bits, we will describe another encoding mechanism, which has higher information rate than Hamming s 2 2 square code. It is called Hamming s [7, 4]-code. Suppose we have the 4-bit word d 1 d 2 d 3 d 4. Define three bits p 1, p 2, p 3 {0, 1} such that in the diagram below, four bits in the same circle add up to 0. The codeword is then p 1 p 2 d 1 p 3 d 2 d 3 d 4. For example, if the bits are 1011, then the diagram above becomes 5

. So p 1 = 0, p 2 = 1, p 3 = 0 and the codeword is 0110011. Suppose you are given a 7-bit message a 1 a 2... a 7. Define the check bits c 1, c 2, c 4 by c 1 = a 1 + a 3 + a 5 + a 7, c 2 = a 2 + a 3 + a 6 + a 7, c 4 = a 4 + a 5 + a 6 + a 7. Then a 1 a 2... a 7 is a codeword if c 1 = c 2 = c 4 = 0. Amazingly if it is different from a codeword by a single digit, the binary number c 4 c 2 c 1 gives the location of error digit. That is why the order p 1 p 2 d 1 p 3 d 2 d 3 d 4 is not arbitrary. Exercise 15 List all the codewords in Hamming s [7, 4]-code. What is the information rate? How does it compare to the information rate of Hamming s 2 2 square code? Exercise 16 Pick your favorite 3-digit decimal number. Convert it to binary number and break it into blocks of 4 bits (add appropriate number 0 to the front to make the number of bits divisible by 4). Then encode each block using Hamming s [7, 4]-code. Exercise 17 Pick a codeword and change a single digit. Calculate the check bits c 1, c 2 and c 4. Treat c 4 c 2 c 1 as a 3-digit binary number and convert it to decimal. Do this a few times and what pattern do you notice? Can you prove it? Exercise 18 Can you generalize Hamming s [7, 4]-code to encoding messages whose numbers of bits are powers of 2? (Hint: In general, it is Hamming s [2 k + k + 1, 2 k ]-code for any integer k). 6