PowerPoint - Mathematics

Download Report

Transcript PowerPoint - Mathematics

MAT 1000
Mathematics in Today's World
Winter 2015
Today
We will look at identification numbers.
An important mathematical idea is to include
a digit in an ID number that allows us to catch
any errors.
These are called “check digits.”
We will look at several different methods for
finding check digits.
Identification numbers
It is common to use numbers as identification.
Examples:
• Credit card numbers identify a line of
credit between a lender and a person.
• UPC codes identify products in a store or
company’s inventory
Identification numbers
Using ID numbers, or codes, simplifies collecting
and processing data.
A store may use coding information to manage
inventory or to record sales information.
Credit card numbers can make some monetary
transactions simpler and safer (as opposed to
personal checks or cash).
Identification numbers
Another advantage of codes:
Coding systems can catch errors.
This uses so-called “check digits.”
Check digit: an extra digit in an ID number
whose purpose is to verify that the rest of the
digits are accurate
Identification numbers
Where do errors come from?
• Human error: typos or misunderstandings
• Transmission errors
• Corrupted files
Identification numbers
Types of errors
Single digit errors:
… 123 … → … 153 …
Multiple digit errors
… 123 … → … 753 …
Transposition errors
… 123 … → … 213 …
“Jump” transpositions
… 123 … → … 321 …
Identification numbers
It is possible to have coding schemes that catch
100% of single-digit errors
We can even make coding schemes that catch
100% of single-digit errors and 100% of
transposition errors
The tradeoff is that to catch more errors the
coding scheme must be more complex.
A simple coding scheme
The following scheme is not used in practice, but
will introduce the key ideas.
For an ID number we choose a check digit so
that the sum of all of the digits of the ID plus
the check digit ends in 0.
A simple coding scheme
Example
ID: 12345
1 + 2 + 3 + 4 + 5 = 15
Our check digit should be a single digit that,
when added to 15, gives a number that ends
in 0.
So the check digit is 5.
ID with check digit: 123455
A simple coding scheme
To verify that this is a valid ID, add up all the digits:
1 + 2 + 3 + 4 + 5 + 5 = 20
The result ends in a 0, so it is valid.
This method catches 100% of single digit errors (even
an incorrect check digit).
A simple coding scheme
Suppose we misread the ID number 123455 as 128455
Add up the digits: 1 + 2 + 8 + 4 + 5 + 5 = 25
The sum does not end in 0, so 12855 is not a valid ID—
we know there was an error.
A few coding themes that are
used
•
•
•
•
•
Division by nine (money orders)
Universal product codes (UPC)
ISBN
Codabars
Zip+4
First we need to understand:
The Division algorithm
Every division has a quotient and
remainder
Division Algorithm
•Divide a by b with remainder r.
a = q ∙ b + r.
•q is the quotient.
•r is the remainder.
•Example: 22 divided by 9 is “2 remainder 4”.
22 = 2 ∙ 9 + 4.
Division-by-9 Check Digits
•Used on US Postal Service money orders.
•First 10 digits identify the money order.
–Each money order has a unique 10-digit number.
•The last digit is a check digit.
•To compute the check digit:
–Add the first ten digits.
–Divide by 9 with remainder.
–The remainder is the check digit.
•Let’s see an example.
Division-by-9 Check Digits
•This system detects some errors in serial numbers.
•It detects single-digit errors, except that:
–It will not detect an error if 9 is replaced by 0.
–It will not detect an error if two digits are switched.
•It detects the presence of an error, but it does not tell
you how to correct the mistake.
•If an error is detected, go back and check for mistakes.
Universal Product Code (UPC)
•The UPC system is used on all grocery products.
•It consists of 12 digits, such as
0 12345 67890 1
•The first digit represents a broad category of items.
•The next five digits identify the manufacturer.
•The next five digits identify the product.
•The last digit is a check digit.
UPC Numbers
Used in many retail products. Here’s an example, along
with a bar code:
As you can see, UPC numbers are 12 digits long. The
first 11 digits are the ID, the last digit is the check
digit.
UPC Numbers
In the UPC coding scheme, odd digits (the first digit,
third digit, fifth digit and so on) are weight 3, and the
even digits are weight 1.
More succinctly, if the UPC number is
𝑎1 𝑎2 𝑎3 𝑎4 𝑎5 𝑎6 𝑎7 𝑎8 𝑎9 𝑎10 𝑎11 𝑎12
Then we compute the weighted sum
3𝑎1 + 𝑎2 + 3𝑎3 + 𝑎4 + 3𝑎5 + 𝑎6 + 3𝑎7 + 𝑎8 + 3𝑎9 + 𝑎10 + 3𝑎11 + 𝑎12
To be a valid UPC number, this sum must end in a 0.
UPC Numbers
In the example given above, the UPC number is
884502115161
To check this is valid, we compute the following
weighted sum:
3⋅8+8+3⋅4+5+3⋅0+2+3⋅1+1+3⋅5+1+3⋅6+1
This works out to 90, so this is a valid UPC number.
UPC Numbers
Suppose we try to read a UPC number, but a digit is
missing.
The following UPC number is missing its first digit:
∎03508072089
Using the UPC coding scheme, we can find the missing
digit.
UPC Numbers
If we call the missing digit 𝑥, then we know the
following sum should end in a 0:
3⋅𝑥+0+3⋅3+5+3⋅0+8+3⋅0+7+3⋅2+0+3⋅8+9
Adding up the 11 terms we do know:
0 + 3 ⋅ 3 + 5 + 3 ⋅ 0 + 8 + 3 ⋅ 0 + 7 + 3 ⋅ 2 + 0 + 3 ⋅ 8 + 9 = 68
So 3 ⋅ 𝑥 + 68 must end in a 0. Using trial and error, we
can test the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
There is only one number 𝑥 which works: 𝑥 = 4. This
must be the missing first digit.
UPC Numbers
The UPC coding scheme catches 100% of single digit
errors, and 89% of most other common errors.
By adding some additional complexity, we can improve
the proportion of errors detected.