MAT 1000 - Mathematics

Download Report

Transcript MAT 1000 - Mathematics

MAT 1000
Mathematics in Today's World
Winter 2015
Today
We will look at more identification numbers and barcodes.
Codabars
The codabar scheme detects 100% of single digit
errors, and 98% of most other common errors.
It is used by all major credit card companies, as
well as blood banks, and some libraries.
It can be used with ID numbers of various lengths.
Credit card numbers are 16 digits long. The last
digit is a check digit.
Codabars
Odd digits are given weight 2, even digits are
weight 1.
This gives the weighted sum
2π‘Ž1 + π‘Ž2 + 2π‘Ž3 + π‘Ž4 + 2π‘Ž5 + π‘Ž6 + 2π‘Ž7 + π‘Ž8 + 2π‘Ž9 + π‘Ž10 + 2π‘Ž11 + π‘Ž12 + 2π‘Ž13 + π‘Ž14 + 2π‘Ž15 + π‘Ž16
However, the codabar system adds an additional
number to this sum.
We add the number 𝑇, which is the number of
digits in odd positions (1, 3, 5, 7, 9, 11, 13, and 15)
that exceed 4.
Codabars
So we find the sum
2π‘Ž1 + π‘Ž2 + 2π‘Ž3 + π‘Ž4 + 2π‘Ž5 + π‘Ž6 + 2π‘Ž7 + π‘Ž8 + 2π‘Ž9 + π‘Ž10 + 2π‘Ž11 + π‘Ž12 + 2π‘Ž13 + π‘Ž14 + 2π‘Ž15 + π‘Ž16 + 𝑇
This is valid if it ends in a 0.
As an example, let’s determine if the following is a
valid credit card number
3125 6001 9643 0012
Codabars
We find 𝑇 first. Look at the digits in positions 1, 3,
5, 7, 9, 11, 13 and 15:
3125 6001 9643 0012
How many of these numbers are larger than 4?
3125 6 001 9 643 0012
There are 2: the 6 in position 5 and the 9 in
position 9.
So 𝑇 = 2
Codabars
Now we compute the weighted sum of the digits
3125 6001 9643 0012
This is
2β‹…3+1+2β‹…2+5+2β‹…6+0+2β‹…0+1+2β‹…9+6+2β‹…4+3+2β‹…0+0+2β‹…1+2
Which equals 68.
Finally we add on 𝑇 = 2, to get 70. This ends in a
0, so the number is valid.
Codabars
Example
Find the check digit for the following credit card
number
3541 0232 0033 227
1. Find 𝑇
The digits in odd positions are
3541 0232 0033 227
Only one of these digits is larger than 4 (the last
digit 7), so 𝑇 = 1
Codabars
3541 0232 0033 227
2. Find the weighted sum of these 15 digits:
2β‹…3+5+2β‹…4+1+2β‹…0+2+2β‹…3+2+2β‹…0+0+2β‹…3+3+2β‹…2+2+2β‹…7
The sum is 59
3. Add 𝑇 = 1
This gives us 60
Codabars
4. Find a check digit that, when added to this sum
gives a last digit of 0.
In this case, our sum 60 already ends in 0, so
our check digit should be 0. That means the
valid number is:
3541 0232 0033 2270
The ISBN-10 Coding System
Is it possible to have a coding system which
catches 100% of single digit errors and 100% of
transposition errors?
Yes. The coding system used for books, called the
ISBN-10 system does this.
ISBN-10 numbers have 10 digits. The last digit is
the check digit.
The ISBN-10 Coding System
The 10-digit ISBN of the textbook for this course is:
1 βˆ’ 4292 βˆ’ 4316 βˆ’ 3
The first digit indicates that the book is published
in an English-speaking country.
The next 4 digits identify the publisher.
The next 4 identify the book.
The last digit is a check digit.
The ISBN-10 Coding System
How can we validate a 10-digit ISBN number?
Once again we use a weighted sum where each
digit gets a different weight:
10π‘Ž1 + 9π‘Ž2 + 8π‘Ž3 + 7π‘Ž4 + 6π‘Ž5 + 5π‘Ž6 + 4π‘Ž7 + 3π‘Ž8 + 2π‘Ž9 + π‘Ž10
There is one more difference from the UPC and
codabar systems: to be a valid ISBN this sum
must be β€œevenly divisible by 11.”
In other words, if we divide by 11 there should be
no remainder.
The ISBN-10 Coding System
How can we tell if a number is evenly divisible by 11?
Divide by 11 and look for a decimal part.
Example
506 is evenly divisible by 11.
506
= 46
11
714 is not evenly divisible by 11
714
= 64.909090 …
11
The ISBN-10 Coding System
The following ISBN is not valid:
1 βˆ’ 2292 βˆ’ 0900 βˆ’ 3
Find the weighted sum of the digits:
10 β‹… 1 + 9 β‹… 2 + 8 β‹… 2 + 7 β‹… 9 + 6 β‹… 2 + 5 β‹… 0 + 4 β‹… 9 + 3 β‹… 0 + 2 β‹… 0 + 3
The sum is equal to 158
But, if we divide 158 by 11, we get 14.363636 …
The result is not a whole number (it has a decimal part), so
158 is not evenly divisible by 11, and the ISBN is not
valid.
The ISBN-10 Coding System
On the other hand, the ISBN for this course’s textbook is
valid:
1 βˆ’ 4292 βˆ’ 4316 βˆ’ 3
The weighted sum is:
10 β‹… 1 + 9 β‹… 4 + 8 β‹… 2 + 7 β‹… 9 + 6 β‹… 2 + 5 β‹… 4 + 4 β‹… 3 + 3 β‹… 1 + 2 β‹… 6 + 3
Which equals 187.
187 ÷ 11 = 17
Since 187 is evenly divisible by 11, the ISBN is valid.
The ISBN-10 Coding System
Unlike the UPC system or the codabar system, the ISBN10 catches all transposition errors. Why isn’t it more
commonly used?
There is one drawback to this system.
Suppose a publisher wants to use the ISBN
1 βˆ’ 4292 βˆ’ 0902
What should the check digit be?
The ISBN-10 Coding System
The weighted sum of these nine digits is 177.
The next integer after 177 that is evenly divisible by 11 is
187.
But that means that to get a valid ISBN we must append a
10, and this is a two-digit number.
In order to keep a standard length of 10 digits, publishers
use an X to represent the 10. So the ISBN-10 in this
case is:
1 βˆ’ 4292 βˆ’ 0902 βˆ’ X
Bar Codes
β€’Written numerals can be hard for
an electronic scanner.
β€’Machines have an easier time
reading black and white stripes.
β€’A bar code is a series of dark bars
and light spaces that encodes a
number.
ZIP Code Bar Codes
β€’Encode ZIP codes as a series of long and short
bars.
β€’Each digit is encoded by 5 bars.
β€’In each block of 5 bars, two are long and three are
short.
β€’Long β€œguard bars” start and end the bar code.
ZIP+4 Codes
β€’ZIP+4 is a 9-digit system with more detailed
address information.
β€’These are encoded the same way, with longer
bar codes.
β€’The tenth digit is a check digit.
How to Compute ZIP+4 Check Digits
β€’Start with zip plus four: π‘Ž1 π‘Ž2 π‘Ž3 π‘Ž4 π‘Ž5 π‘Ž6 π‘Ž7 π‘Ž8 π‘Ž9 .
β€’Compute π‘Ž1 + π‘Ž2 + π‘Ž3 + π‘Ž4 + π‘Ž5 + π‘Ž6 + π‘Ž7 + π‘Ž8 +
π‘Ž9 .
β€’Divide by 10 with remainder (easy!).
β€’The check digit π‘Ž10 is
 0 if r = 0.
 10 – r if r > 0.
β€’π‘Ž1 + π‘Ž2 + π‘Ž3 + π‘Ž4 + π‘Ž5 + π‘Ž6 + π‘Ž7 + π‘Ž8 + π‘Ž9 + a10
is always a multiple of 10.
UPC Bar Codes
β€’UPC bar codes are similar to ZIP code bar codes.
β€’Instead of short and long bars, the information is
carried in the widths of the bars and spaces.
β€’This works well with supermarket optical scanners.
β€’What if you scan an item backwards?
β€’The UPC bar codes use different patterns for the
first half and the second half.