Appendix: a brief history of numbers ‘God created the natural numbers. Everything else is the work of man.’ Leopold Kronecker (1823–1891) Fundamentals of Computing 2011–12 (2, appendix) http://www.dcs.bbk.ac.uk/~michael/foc/foc.html 1 Natural numbers Natural numbers 0, 1, 2, 3, 4, . . . have two main purposes: – they can be used for counting — ‘there are 3 apples on the table’ – they can be used for ordering — ‘this is the 3rd largest city in the country’ What’s the largest number? Numeral systems A numeral is a symbol or group of symbols that represents a number – Unary: numeral ||||||| means – Decimal: numeral 456 means (4 × 102 ) + (5 × 101 ) + (6 × 100 ) numeral 101 means (1 × 102 ) + (0 × 101 ) + (1 × 100 ) numeral 101 means (1 × 22 ) + (0 × 21 ) + (1 × 20 ), – Binary: – ... Fundamentals of Computing 2011–12 (2, appendix) 7 i.e., decimal 5 http://www.dcs.bbk.ac.uk/~michael/foc/foc.html 2 Basic arithmetic operations – Addition (+) || + ||| = |||||, – Multiplication (×) || × ||| = || || ||, 7 + 5 = 12, . . . 7 × 5 = 35, . . . Operations + and × are defined for all natural numbers: if n and m are natural numbers then n + m and n × m are natural numbers as well – Subtraction (−) (inverse of +) 12 − 7 = 5 – Division (/) (inverse of ×) 35/7 = 5 What is 7 − 12? What is 7/35? For any natural numbers a and b 6= 0, there are unique numbers q (quotient) and r (remainder) such that 0 ≤ r < b and a = (b×q)+r If r = 0 then we say that a is divisible by b For example, 26 = 10 × 2 + 6, or Fundamentals of Computing 2011–12 (2, appendix) 26/10 is 2 with remainder 6 http://www.dcs.bbk.ac.uk/~michael/foc/foc.html 3 Prime numbers A prime number (or prime) is a natural number greater than 1 whose only positive divisors are 1 and itself. Or for short: a prime number is a natural number with exactly two natural divisors. The property of being a prime is called primality. The sequence of prime numbers begins 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, . . . The fundamental theorem of arithmetic: every natural number larger than 1 can be written as a product of primes in a unique way, i.e., unique except for the order. Primes are thus the ‘basic building blocks’ of the natural numbers. For example, we can write 23244 = 22 × 3 × 13 × 149 and any other such factorisation of 23244 will be identical except for the order of the factors. Euclid (325-265 BC): There are infinitely many prime numbers. (Why?) The largest known prime, as of August 2008, is 243,112,609 − 1 (this number is 12, 978, 189 digits long). In 2005, the largest known prime was 230402457 − 1 (9, 152, 052 digits long). Fundamentals of Computing 2011–12 (2, appendix) http://www.dcs.bbk.ac.uk/~michael/foc/foc.html 4 Two open problems Goldbach’s conjecture (1742): every even number a > 2 can be represented as the sum a = b + c of two prime numbers b and c For example, 18 = 11 + 7, 100 = 97 + 3, . . . Shnirelman (1931) showed that every natural number can be represented as a sum of at most 300, 000 primes. This result was subsequently improved by many authors; currently, the best known result is due to O. Ramaré, who in 1995 showed that every even number n ≥ 4 is in fact the sum of at most 6 primes. Twin prime conjecture: there are infinitely many twin primes, pairs of primes with difference 2, such as 5 and 7, or 29 and 31 On May 26, 2004, R. Arenstorf of Vanderbilt University submitted a 38-page proof that there are, in fact, infinitely many twin primes. On June 3, M. Balazard of University Bordeaux reported that Lemma 8 on page 35 is false. As is typical in mathematical proofs, the defect may be correctable or a substitute method may repair the defect. Arenstorf withdrew his proof on June 8, noting “A serious error has been found in the paper, specifically, Lemma 8 is incorrect.” Largest known twins: 65516468355 × 2333333 + 1 and 65516468355 × 2333333 − 1 Fundamentals of Computing 2011–12 (2, appendix) http://www.dcs.bbk.ac.uk/~michael/foc/foc.html 5 Integer and rational numbers by generalisation By ‘closing’ the natural numbers under subtraction (inverse of +) we obtain integer numbers . . . , −3, −2, −1, 0, 1, 2, . . . By ‘closing’ the integer numbers under division (inverse of ×) we obtain rational numbers of the form m/n, where m, n are integers and n 6= 0 Another reason for introducing rational numbers is to use them for approximate measurements (length, area, weight, time, etc.). 35 hours For example, 12 hours 35 minutes, that is 12 60 Decimal representation of rational numbers 833/100 = 8.33 = 8 + 3/10 + 3/100 = 8 × 100 + 3 × 10−1 + 3 × 10−2 1/3 = 0.333333 . . . = 0 + 3/10 + 3/100 + 3/1000 + · · · 1/11 = 0.090909 . . . = 0 + 0/10 + 9/100 + 0/1000 + 9/10000 + · · · (with 09 recurring) Any rational number which cannot be expressed as a (finite) decimal fraction has a unique infinite decimal expansion ending with recurring decimals. Fundamentals of Computing 2011–12 (2, appendix) http://www.dcs.bbk.ac.uk/~michael/foc/foc.html 6 Basic arithmetic laws The rationals m/n are still called numbers (remember, originally only natural numbers were ‘numbers’) because basic arithmetic laws extend to rational numbers as well. Namely, for all natural and, moreover, rational numbers, we have a+b a + (b + c) a×b a × (b × c) a × (b + c) = = = = = b+a (a + b) + c b×a (a × b) × c (a × b) + (a × c) (commutativity of +) (associativity of +) (commutativity of ×) (associativity of ×) (distributivity of × over +) Interesting: the rule (−1) × (−1) = 1 (which is basic for multiplication of negative numbers) is a consequence of our desire to keep distributivity for rational numbers. This rule cannot be proved; it was created or declared ‘artificially’ without violating the basic arithmetic laws. Fundamentals of Computing 2011–12 (2, appendix) http://www.dcs.bbk.ac.uk/~michael/foc/foc.html 7 Basic arithmetic operations (cont.) – Exponentiation: given a rational number a and a natural number n, an = a × a × · · · × a | {z } for n > 0, a0 = 1 n – – – Radicals or roots: given a rational a > 0 and a natural n, the nth root or √ radical of a is the number b, written as n a , such that bn = a n am = √ m an a−b = 1 ab Logarithm: the logarithm of a number a relative to a base b is the number c, written as logb a , such that bc = a. For example, log2 32 = 5 Radicals and logarithms are not defined for all rational numbers. . . What is √ 2? What is log2 3? Fundamentals of Computing 2011–12 (2, appendix) What is √ −1? http://www.dcs.bbk.ac.uk/~michael/foc/foc.html 8 Irrational numbers Claim: log2 3 is irrational (in the sense that there are no integer numbers n and m such that log2 3 = n/m) Proof by contradiction (or reductio ad absurdum): (1) Assume, hypothetically, that there are integers n and m such that log2 3 = n/m (2) Then show that this assumption leads us to an absurd, impossible situation, that is, to a contradiction Indeed, log2 3 = n/m means that 2n = 3m . But this is impossible, since 2n is even and 3m is odd. Therefore, log2 3 cannot be rational. Fundamentals of Computing 2011–12 (2, appendix) http://www.dcs.bbk.ac.uk/~michael/foc/foc.html 9 Irrational numbers (cont.) Claim: √ 2 is irrational Proof: (1) Assume the contrary, that is, √ 2 = a/b for some integers a and b. (2) By dividing both a and b by all the factors that are common to both, we √ obtain 2 = m/n, for some integers m and n having no common factors √ So we have 2 · n = m. Squaring both sides we obtain 2n2 = m2 , and therefore m should be even, that is, m = 2k for some integer k. So we have 2n2 = (2k)2 , so 2n2 = 4k2 , and so n2 = 2k2 . Therefore, n should be even as well. So 2 is a common factor of m and n. But they have no common factor, which is a contradiction Fundamentals of Computing 2011–12 (2, appendix) http://www.dcs.bbk.ac.uk/~michael/foc/foc.html 10 Sad story :-) The discovery of irrational numbers is usually attributed to Pythagoras, more specifically to the Pythagorean Hippasus of Metapontum, who produced a (most likely geometrical) proof of the irrationality of the square root of 2. The story goes that Hippasus discovered irrational numbers when trying to represent the square root of 2 as a fraction (proof above). However Pythagoras believed in the absoluteness of rational numbers, and could not accept the existence of irrational numbers. He could not disprove their existence through logic, but his beliefs would not accept the existence of irrational numbers and so he sentenced Hippasus to death by drowning. Fundamentals of Computing 2011–12 (2, appendix) http://www.dcs.bbk.ac.uk/~michael/foc/foc.html 11 Real numbers By Pythagoras’ Theorem, √ 2 can be regarded as the length of the hypotenuse in the right-angled triangle with legs of length 1 We can approximate this length by means of rational numbers and obtain a sequence 1, 1.4, 1.41, 1.4142, 1.414213562, ... The three dots indicate that there would still be more dots to come, no matter how many more might be added to the end. √ We can define 2 as the limit of this sequence. In this respect, 1/3 is represented as 0.3333 . . . , (Why?) 1 as 0.9999999 . . . (Remember, periodic fractions represent rational numbers.) In general, real numbers can be defined as decimal (or binary, or . . . ) fractions that have an infinite sequence of digits to the right of the decimal (binary, etc.) point. Real numbers measure continuous quantities like lengthes, weights, etc. Fundamentals of Computing 2011–12 (2, appendix) http://www.dcs.bbk.ac.uk/~michael/foc/foc.html 12 Real numbers and computers A real number is said to be computable if there exists an algorithm that yields its digits. As we shall see later, most real numbers are not computable. Some ‘constructivists’ accept the existence of only those reals that are computable. The set of definable numbers is broader, but still only countable. Computers can only approximate most real numbers. Most commonly, they can represent a certain subset of the rationals exactly, via either floating point numbers or fixed-point numbers, and these rationals are used as an approximation for other nearby real values. Arbitrary-precision arithmetic is a method to represent arbitrary rational numbers, limited only by available memory, but more commonly one uses a fixed number of bits of precision determined by the size of the processor registers. In addition to these rational values, computer algebra systems are able to treat many irrational numbers exactly by storing an √ algebraic description (such as 2) rather than their rational approximation. Fundamentals of Computing 2011–12 (2, appendix) http://www.dcs.bbk.ac.uk/~michael/foc/foc.html 13 Graphs of arithmetic functions 2x exponential order of growth 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 . . x2 x 0 1 2 3 4 5 6 10100 seconds ≈ 3.168 × 1092 years Fundamentals of Computing 2011–12 (2, appendix) 7 quadratic order of growth linear order of growth log10 x logarithmic order of growth (Age of the universe ≈ 1.5 × 109 years) http://www.dcs.bbk.ac.uk/~michael/foc/foc.html 14 Prefixes indicating quantity Prefix nano micro milli centi deci deca hecto kilo mega giga tera Symbol n µ m c d da, D h, H k, K M G T Size 10−9 10−6 10−3 10−2 10−1 10 102 103 106 109 1012 Decimal equivalent Comes from Greek 0.000 000 001 dwarf 0.000 001 small 0.001 Latin thousand 0.01 Latin hundred 0.1 Latin tenth 10 a factor of ten 100 hundred 1 000 thousand 1 000 000 great 1 000 000 000 giant 1 000 000 000 000 monster Fundamentals of Computing 2011–12 (2, appendix) http://www.dcs.bbk.ac.uk/~michael/foc/foc.html 15 However, in Computer Science . . . – Tera can sometimes mean 1099511627776 (240 ) instead of 1000000000000, especially in the term terabyte – Giga can sometimes mean 1073741824 (230 ) for information units, e.g., gigabit or gigabyte, but can also denote 1000000000 of other quantities, e.g., transfer rates: 1 gigabit/s = 1000000000 bit/s – Mega can sometimes denote 1048576 (220 ) of information units, e.g., a megabyte, but can denote 1000000 (106 ) of other quantities, for example, transfer rates: 1 megabit/s = 1000000 bit/s – Kilo does not always exactly denote 1000 but is usually equivalent to 1024 (210 ), most often when denoting storage. For example, a kilobyte is frequently 1024 bytes, and not 1000 bytes as it should be. A common convention is to use ‘k’ for 1000 and ‘K’ for 1024. Fundamentals of Computing 2011–12 (2, appendix) http://www.dcs.bbk.ac.uk/~michael/foc/foc.html 16