MATH 1020: Mathematics For Non-science Chapter 4: Information in a networked age Instructor: Prof. Ken Tsang Room E409-R9 Email: kentsang@uic.edu.hk 1 Transmitting Information – Binary codes – Data compression – Encoding with parity-check sums – Cryptography – Model the genetic code 2 Information , data & numbers Today information are transmitted all over the world through the internet Information is just collection of data – Pictures – jpg, tif … – Sound – mp3, mp4 – Video – wmv, mvb Data consisted of numbers 3 Decimal Number System As human normally counts with hands and there are totally 10 fingers on both hands, this probably explains the origin of the decimal number system. 10 digits: – 0,1,2,3,4,5,6,7,8,9 Also called base-10 number system, – Or Hindu-Arabic, or Arabic system Counting in base-10 – 1,2,…,9,10,11,…,19,20,21,…,99,100,… Decimal number in expanded notation – 234 = 2 * 100 + 3 * 10 + 4 * 1 4 Hindu–Arabic numeral system The Brahmi (ancient Indian) numerals at the basis of the system predate the Common Era. The development of the positional decimal system occurred during the Gupta period (笈多王朝, 320 to 540 CE). Aryabhata, a Gupta period scholar, is believed to be the first to come up with the concept of zero. These Indian developments were taken up in Islamic mathematics in the 8th century. A young Italian in the 12th century, Fibonacci, traveled throughout the Mediterranean world to study under the leading Arab mathematicians of the time, recognizing that arithmetic with Hindu-Arabic numerals is simpler and more efficient than with Roman numerals. 5 Fibonacci (1170-1250 CE) Italian mathematician, Leonardo Fibonacci (through the publication in 1202 of his Book of Calculation, the Liber Abaci) introduced the Arabic numerals, the use of zero, and the positional decimal system to the Latin world. Liber Abaci showed the practical importance of the new numeral system, by applying it to commercial bookkeeping. The numeral system came to be called "Arabic" by the Europeans. It was used in European mathematics from the 12th century, and entered common use from the 15th century. Fibonacci significantly influenced the evolution of capitalist enterprise and public finance in Europe in the centuries that followed. 6 Positional Numbering System The value of a digit in a number depends on: – The digit itself – The position of the digit within the number So 123 is different from 321 – 123: 1 hundred, 2 tens, and 3 units – 321: 3 hundred, 2 tens, and 1 units 7 Roman numerals Roman numerals are numeral system of ancient Rome based on the letters of the alphabet The first ten Roman numerals are I, II, III, IV, V, VI, VII, VIII, IX, and X. (no zero) Tens: X; hundreds: C; thousands: M Non-positional: e.g. – 321 CCCXXI – 982 CMLXXXII – 2010 MMX 8 Non-decimal Number Systems The Maya civilization and other civilizations of preColumbian Mesoamerica used base-20 (vigesimal), as did several North American tribes (two being in southern California). Evidence of base-20 counting systems is also found in the languages of central and western Africa. The Irish language also used base-20 in the past. Danish numerals display a similar base-20 structure. 9 Base r Number System For any value r Value is based on the sum of a power series in powers of r r is called the base, or radix 10 Binary Number System Binary number system has only two digits – 0, 1 – Also called base-2 system Counting in binary system – 0, 1, 10, 11, 100, 101, 110, 111, 1000,…. Binary number in expanded notation – (1011)2 = 1*23 – (1011)2 = 1*8 + 0*22 + 1*21 + 1*20 + 0*4 + 1*2 + 1*1 = (11)10 11 Why Binary? Computer is a Binary machine It knows only ones and zeroes Easy to implement in electronic circuits Reliable Cheap 12 Gottfried Leibniz (1646-1716) Leibniz, German mathematician and philosopher, invented at least two things that are essential for the modern world: calculus, and the binary system. He invented the binary system around 1679, and published in 1701. This became the basis of virtually all modern computers. 13 Leibniz & I-Ching (易经) As a Sinophile, Leibniz was aware of the IChing and noted with fascination how its hexagrams correspond to the binary numbers, and concluded that this mapping was evidence of major Chinese accomplishments in the sort of philosophical mathematics he admired. 14 An ancient Chinese binary number system in Yi-Jing (易经) Two symbols to represent 2 digits Zero: represented by a broken line One: represented by an unbroken line “—” yan 阳爻,“--” yin 阴爻。 15 Hexadecimal Hexadecimal number system has 16 digits • 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F • Also called base-16 system Counting in Hexadecimal – 0,1,…,F,10,11,…,1F,20,…FF,100,… Hexadecimal number in expanded notation – (FF)16 = 15*161 + 15*16 0 = (255)10 16 Conversion between binary & hexadecimal for the first 16 numbers 17 Why Hexadecimal? Hexadecimal is meaningful to humans, and easy to work with for a computer Compact – A BYTE is composed of 8 bits – One byte can thus be expressed by 2 digits in hexadecimal – 11101111 EF – 11101111b EFh Simple to convert them to binary 18 Conversions Between Number Systems Binary to Decimal 19 Conversions Between Number Systems Octal to Decimal – (32)8 = (?)10 What’s wrong? – (187)8 = 1*64 + 8*8 + 7*1 20 Conversions Between Number Systems Decimal to Binary 32110 = ?2 quotient remainder 321 / 2 = 160 160 / 2 = 80 80 / 2 = 40 40 / 2 = 20 20 / 2 = 10 10 / 2 = 5 5/2 =2 2/2 =1 1/2 =0 1 0 0 0 0 0 1 0 1 from bottom to top, we have Reading the remainders 32110 = 1010000012 21 Analogue Data Analogue: something that is analogous or similar to something else (Webster) Analogue Data: The use of continuously changing quantities to represent data. A mercury thermometer is an analogue device. The mercury rises and falls in a continuous flow in the tube in direct proportion to the temperature. The mathematical idealization of this smooth change as a continuous function leads to “Analogue Data”, an infinite amount of data 22 From Analogue to Digital data Data can be represented in one of two ways: analogue or digital: Analogue data: A continuous representation (using mathematical function or smooth curve) , analogous to the actual information it represents Digital data: A discrete representation, breaking the information up into separate elements (data) 23 Digitized Information Computers, cannot work with analogue information So we digitize information by breaking it into pieces and representing those pieces separately Why do we use binary? – Modern computers are designed to use and manage binary values because the devices that store and manage the data are far less expensive and far more reliable if they only have to represent one of two possible values. 24 Bit and Byte BIT = Binary digIT, “0” or “1” State of on or off ( high or low) of a computer circuit Kilo 1K = 210 = 1024 ≈ 103 Mega Giga 1M = 220 = 1,048,576 ≈ 106 1G = 230 = 1,073,741,824 ≈ 109 25 Bit and Byte Byte is the basic unit of addressable memory 1 Byte = 8 Bits The right-most bit is called the LSB Least Significant Bit The Left-most bit is called the MSB Most Significant Bit 26 Binary Representation One bit can be either 0 or 1 (“on” & “off” electronic signals) Therefore, one bit can represent only two things To represent more than two things, we need multiple bits Two bits can represent four things because there are four combinations of 0 and 1 that can be made from two bits: 00, 01, 10, 11 27 Binary Representation n In general, n bits can represent 2 things n because there are 2 combinations of 0 and 1 that can be made from n bits Note that every time we increase the number of bits by 1, we double the number of things we can represent Questions: – How many bits are needed to represent 128 things? – How many bits are needed to represent 67 things? 28 ASCII ASCII stands for American Standard Code for Information Interchange The ASCII character set originally used seven bits to represent each character, allowing for 128 unique characters Later ASCII evolved so that all eight bits were used which allows for 256 characters 29 ASCII code 30 Unicode characters Extended version of the ASCII character set is not enough for international use The Unicode character set uses 16 bits per character – Therefore, the Unicode character set can represent 216, or over 65 thousand, characters Unicode was designed to be a superset of ASCII – The first 256 characters in the Unicode character set correspond exactly to the extended ASCII character set With the Unicode, all text (in most languages) information can be represented. 31 4 Hex-numerals to represent 1 Unicode Unicode 32 Representing Audio Information To digitize the signal we periodically measure the voltage of the signal and record the appropriate numeric value – this process is called sampling In general, a sampling rate of around 40,000 times per second is enough to create a reasonable sound reproduction 33 Representing Audio Information 34 Representing Audio Information • A compact disk (CD) stores audio information digitally • On the surface of the CD are microscopic pits that represent Binary digits •A low intensity laser is pointed as the disc •The laser light reflects strongly if the surface is smooth and reflects poorly if the surface is pitted 35 Representing Audio Information Audio Formats – WAV, AU, AIFF, VQF, and MP3 MP3 is dominant – MP3 is short for MPEG (Moving Picture Experts Group) audio layer 3 file – MP3 employs both lossy and lossless compression – First it analyzes the frequency spread and compares it to mathematical models of human psychoacoustics (the study of the interrelation between the ear and the brain), then it discards information that can’t be heard by humans – Then the bit stream is compressed to achieve additional compression 36 Image Basics 00000000000000000011110000000000000000 00000000000000001100001100000000000000 00000000000000010000000010000000000000 00000000000000100000000001000000000000 00000000000000100010001001000000000000 00000000000001000111011100100000000000 00000000000001000010001000100000000000 00000000000001000000000000100000000000 00000000000001000000000000100000000000 00000000000001001000000100100000000000 00000000000000100100001001000000000000 00000000000000100011110001000000000000 00000000000000010000000010000000000000 00000000000000001100001100000000000000 00000000000000000011110000000000000000 00011110010000000000000000000000000000 01100010010000000000000000000000000000 11000100100000000000000000000000000000 00000100100001110001011000101100100100 00111111110010010001101000110101100100 00001001000100100111001011100101001000 00010010000101101010010101001011011010 00010010000110110111111011111101101100 00000000000000000100000010000000011000 00000000000000001100000110000000110000 00000000000000001000000100000000100000 38 1-bit, black and white 8-bit grayscale 40 Representing Color Color is often expressed in a computer as an RGB (red-green-blue) value, which is actually three numbers that indicate the relative contribution of each of these three primary colours For example, an RGB value of (255, 255, 0) maximizes the contribution of red and green, and minimizes the contribution of blue, which results in a bright yellow 41 RGB Model RGB Color Model – Red – Green – Blue – Additive model combines varying amounts of these 3 colors 42 Image Basics (0, 255, 0) is green (255, 255, 0) is yellow (255, 0, 0) is red (0, 255, 255) is cyan (0, 0, 255) is blue (0, 0, 0) is black (255, 255, 255) is white (255, 0, 255) is magenta 45 Composing color image Store the actual intensities of R, G, and B individually in the framebuffer 24 bits per pixel = 8 bits red, 8 bits green, 8 bits blue DAC 46 Digitized Images and Graphics Digitizing a picture is the act of representing it as a collection of individual dots called pixels The number of pixels used to represent a picture is called the resolution Several popular raster file formats including bitmap (BMP), GIF, and JPEG 49 Image Basics Bitmap – Grid of pixels 50 BMP 51