Highlights of Computing: From the Ancient Indian Vedic Literature to Modern Practical Cryptography

Uwe Wystup

uwe.wystup@mathfinance.com

February 2010

1

Uwe Wystup - Highlights of Computing

2

Contents
1 Numeral Systems 1.1 Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Vedic Mathematics 2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . 2.1.1 The 16 Sutras . . . . . . . . . . . . . . . . . 2.1.2 Jagadguru Swami Sri Bharati Krsna Tirthaji 2.2 Multiplication . . . . . . . . . . . . . . . . . . . . . 2.2.1 Exercises . . . . . . . . . . . . . . . . . . . . 2.3 Squares . . . . . . . . . . . . . . . . . . . . . . . . 2.3.1 Exercises . . . . . . . . . . . . . . . . . . . . 2.4 Division . . . . . . . . . . . . . . . . . . . . . . . . 2.4.1 Exercises . . . . . . . . . . . . . . . . . . . . 2.5 Divisibility . . . . . . . . . . . . . . . . . . . . . . . 2.5.1 Exercises . . . . . . . . . . . . . . . . . . . . 2.6 Square Roots (Vargamula) . . . . . . . . . . . . . . 2.6.1 Duplex Process (Dvandvayoga) . . . . . . . 2.6.2 Square Root of a Perfect Square . . . . . . . 2.6.3 Exercises . . . . . . . . . . . . . . . . . . . . 3 Zero Search Methods 3.1 Newton’s Method . . . . . . . . . . . 3.1.1 Problems . . . . . . . . . . . 3.1.2 Rate of Convergence . . . . . 3.2 Heron’s Square Root Finder . . . . . 3.3 Exercise: Divisions without Dividing 3 3 4 4 5 6 6 8 10 11 11 12 13 14 14 15 15 17 17 18 19 20 21 21

. . . . . . . . . . . . Maharaja . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

4 Credit Cards 21 4.1 The Luhn Algorithm . . . . . . . . . . . . . . . . . . . . . . . 22 4.2 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 5 Cryptography 5.1 The Inventors of the RSA-Algorithm (1978) 5.2 Method . . . . . . . . . . . . . . . . . . . . 5.3 Examples . . . . . . . . . . . . . . . . . . . 5.4 Exercise . . . . . . . . . . . . . . . . . . . . 24 24 26 27 28

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

6 Definitions 28 6.1 Prime Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . 28 6.2 Modulus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

Uwe Wystup - Highlights of Computing 7 Contact Information 1. Numeral Systems 2. Vedic Mathematics 3. Zero Search Methods 4. Credit Cards 5. Cryptography 6. Definitions

3 29

1

Numeral Systems
• Fundamentals: Any integer has a unique representation as a weighted sum of powers of a chosen base. • Example: 245 = 2 · 102 + 4 · 101 + 5 · 100

The Base 10 is in no way special except that

• The Mayas also used the feet (base=20), see http://en.wikipedia.org/ wiki/Maya_numerals. • Computers use a dual system (power off or on, base 2) or a hexadecimal system (0, 1, 2, . . . , 9, A, B, C, D, E, F ) for memory size: 1 byte = F F . • More on http://en.wikipedia.org/wiki/Numeral_system

1.1

Exercise

Write the hexadecimal number CAF E in the dual, decimal and Maya number system.

Uwe Wystup - Highlights of Computing

4

2

Vedic Mathematics
1. Introduction 2. Multiplication 3. Squares 4. Division 5. Divisibility 6. Square Roots

2.1

Introduction

veda (Sanskrit) means: knowledge Veda Rigveda Samaveda Yajurveda Atharvaveda Upaveda Ayurveda Gandharvaveda Dhanurveda Sthapatyaveda

Table 1: Vedas and Upavedas (supplementary vedas)

Uwe Wystup - Highlights of Computing 2.1.1 The 16 Sutras

5

are part of a Parisista (Appendix) of the Atharvaveda
1. By one more than the one before 2. All from 9 and the last from 10 3. Vertically and crosswise 4. Transpose and apply 5. If the Samuccaya is the same it is zero 6. If one is in ratio the other is zero 7. By addition and by subtraction 8. By the completion or non-completion 9. Differential calculus 10. By the deficiency 11. Specific and general 12. The remainders by the last digit 13. The ultimate and twice the penultimate 14. By one less than the one before 15. The product of the sum 16. All the multipliers

Uwe Wystup - Highlights of Computing 2.1.2 Jagadguru Swami Sri Bharati Krsna Tirthaji Maharaja

6

Explained the sutras in his books. Jagadguru Swami Sri Bharati Krsna Tirthaji Maharaja (March, 1884 February 2, 1960) was the Jagadguru (literally, teacher of the world; assigned to heads of Hindu mathas) of the Govardhana matha of Puri during 19251960. He was one of the most significant spiritual figures in Hinduism during the 20th century. He is particularly known for his work on Vedic mathematics.

2.2

Multiplication

Example with working base 10:

9

×

1

7

×

3

13

+ ×

3

12

+ ×

2

7 6

/ =

3 3 63

6

-

4 2 42

12 15

+ / =

2 6 156

8 10

/ =

2 ¯ 4 96

3 /1 =

Reason: (x + a)(x + b) = x(x + a + b) + ab Origin of the ×-sign comes from this method

Uwe Wystup - Highlights of Computing Example with working base 100:

7

91

×

9

111

+ ×

11

108

+ ×

8

96 87

/ =

4 36 8736

109 120

+ / =

9 99 12099

97 105

/ =

3 ¯ 24 10476

Other working bases (division case)

100/2=50 49 × 49 2)48 24 / / = 1 01 01 2401 1

100/2=50 54 + × 46 2)50 25 / / = 4 ¯6 1¯ ¯¯ 16 2484 4

Other working bases (multiplication case)

10× 2=20 19 × 19 × 2)18 36 / / = 1 1 1 361 1

10× 6=60 62 + × 48 × 6)50 300 /¯ 2 /¯ 2 = 12 ¯ 4 ¯ 4 2976 2

Uwe Wystup - Highlights of Computing 2.2.1 Exercises

8

Multiply the following a 94 × 94 b 97 × 89 c 87 × 99 d 87 × 98 e 87 × 95 f 95 × 95 g 79 × 96 h 98 × 96 i 92 × 99 j 88 × 88 k 97 × 56 l 97 × 63 m 92 × 196

Uwe Wystup - Highlights of Computing Multiply the following mentally a 667 × 998 b 768 × 997 c 989 × 998 d 885 × 997 e 883 × 998 f 8×6 g 891 × 989 h 8888 × 9996 i 6999 × 9997 j 90909 × 99994 k 78989 × 99997 l 9876 × 9989

9

Uwe Wystup - Highlights of Computing Multiply the following mentally a 133 × 103 b 107 × 108 c 171 × 101 d 102 × 104 e 132 × 102 f 14 × 12 g 18 × 13 h 1222 × 1003 i 1051 × 1007 j 15111 × 10003 k 125 × 105 l 10607 × 10008

10

2.3

Squares

Using the sutra Ekadhikena Purvena (“by one more than the previous one”) we get 152 = 1 × 2/25 = 2/25 = 225 252 = 2 × 3/25 = 6/25 = 625 352 = 3 × 4/25 = 12/25 = 1225 . . . 2 115 = 11 × 12/25 = 132/25 = 13225

Uwe Wystup - Highlights of Computing 2.3.1 Exercises

11

Multiply the following mentally a 652 b 852 c 0.52 d 7.52 e 0.02252 f 10502 g 1752

2.4

Division
1 . 19

• Lots of tricks are available. We do only some highlights. • Find the exact decimal representation of • Standard methods are cumbersome. • Using the “Ekadhika Purva” Sutra it is easy: • Start with 1 and then work from right to left multiplying by 2. . 1 0 5 1 2 6 3 1 1 1 5 1 7 1 8 / 9 1 4 7 1 3 1 6 8 4 2 1

Uwe Wystup - Highlights of Computing • A further shortcut is the insight that . + = 0 9 9 5 4 9 2 7 9 6 3 9 3 6 9 1 8 9 5 4 9 7 2 9 8 1 9

12

• The same works for all periodic decimals, e.g. . + = 1 8 9 4 5 9 2 7 9

1 7

2.4.1

Exercises

Compute the exact decimal number of a b
1 29 1 49

Uwe Wystup - Highlights of Computing

13

2.5

Divisibility

• Use Ekadhika as an osculator. • For 9, 19, 29, 39 etc. the Ekadhikas are 1, 2, 3, 4, etc. • For 3, 13, 23, 33 etc. multiply them by 3 and you get 1, 4, 7, 10, etc. as the Ekadhikas. • For 7, 17, 27, 37 etc. multiply them by 7 and you get 5, 12, 19, 26, etc. as the Ekadhikas. • For 1, 11, 21, 31 etc. multiply them by 9 and you get 1, 10, 19, 28, etc. as the Ekadhikas. • Now test if 112 is divisible by 7 osculating by 5: 2 × 5 + 11 = 21, which is divisible by 7. • Therefore: yes Is 2774 divisible by 19? Osculate by 2: 2 7 + 2 + 1 3 + 1 1 6 9 8 0 8 7 8 5 4

Uwe Wystup - Highlights of Computing • One more example: Is 5293240096 divisible by 139? • The Ekadhika (osculator) is 14. 5 139 2 89 9 36 3 131 2 29 4 131 0 19 0 51 9 93 6

14

• Answer: yes 2.5.1 Exercises

Using the osculation method, check if a 32896 is divisible by 29 b 93148 is divisible by 29 c 4914 is divisible by 39 d 14061 is divisible by 43

2.6

Square Roots (Vargamula)

• 1, 5, 6 and 0 at the end of a number reproduce themselves as the last digits in the square. • Squares of complements from 10 have the same last digit; thus 12 and 92 end in 1, 22 and 82 end in 4 etc. • 2, 3, 7 and 8 are out of court altogether. • If the given number has n digits, then the square root will contain n+1 digits. 2
n 2

or

• Systematic computation of an exact square root requires the Dvandvayoga (Duplex) process.

Uwe Wystup - Highlights of Computing 2.6.1 Duplex Process (Dvandvayoga) D(4) D(43) D(137) D(1034) D(10345) Got it? 2.6.2 Find √ Square Root of a Perfect Square 1849. = = = = = 42 = 16 2 · 4 · 3 = 24 2 · 1 · 7 + 32 = 23 2·1·4+2·0·3=8 2 · 1 · 5 + 2 · 0 · 4 + 32 = 19 (1) (2) (3) (4) (5)

15

Group in pairs, taking a single extra digit on the left as extra digit.

1 8)

8

— 2

4

9

4

4 is the largest integer whose square does not exceed 18. 18/4 is 4 with remainder 2. The divisor 8 is two times 4. Next we divide 24 by the divisor 8. This gives 3 remainder 0, placed as 1 8) 4 8 — 2 3 4 0 9

Now we see 09 and we deduct from this the duplex of the last answer figure 3, i.e. 09 − D(3) = 09 − 32 = 09 − 9 = 0. This means that the answer is exactly 43.

Uwe Wystup - Highlights of Computing

16

1 6)

3

— 4

6

9

3

3 is the largest integer whose square does not exceed 13. 13/3 is 3 with remainder 4. The divisor 6 is two times 3. Next we divide 46 by the divisor 6. This gives 7 remainder 4, placed as 1 6) 3 3 — 4 7 6 4 9

49 − D(7) = 0, so 37 is the exact square root of 1369.

Uwe Wystup - Highlights of Computing 2.6.3 Exercises

17

Find the square root of the following. a 3136 b 3969 c 5184 d 3721 e 6889 f 1296 Find out how the method extends to 6-digit squares and find the square roof of the numbers a 119025 b 524176 c 519841 d 375769

3

Zero Search Methods
1. Newton’s Method 2. Heron’s Square Root Finder 3. Exercise: Divisions without Dividing

Uwe Wystup - Highlights of Computing

18

Sir Isaac Newton 1643 - 1727

3.1

Newton’s Method

Given a differentiable function f (x) we want to determine x such that ˆ f (ˆ) = 0. x (6)

Starting with x0 we take the tangent to the curve through the point (x0 , f (x0 )) and use its intersection with the x-axis x1 as a new starting point. We repeat this method until no further changes occur. The recursive relation is xn+1 = xn − and the result is
n→∞

f (xn ) f (xn )

(7)

lim xn = x. ˆ

(8)

Uwe Wystup - Highlights of Computing

19

Newton’s Method - graphically

3.1.1

Problems

Problems can occur due to 1. multiple solutions 2. non convex f , reflection points 3. solutions at extreme values 4. |f | = ∞ 5. pathological cases

Uwe Wystup - Highlights of Computing 3.1.2 Rate of Convergence

20

Considering all these problems, why is Newton’s method still so popular? The reason lies in the rate of convergence. Define the error by en = xn − x ˆ From the definition of the Newton iteration, we have en+1 = xn+1 − x ˆ f (xn ) = xn − −x ˆ f (xn ) f (xn ) = en − f (xn ) en f (xn ) − f (xn ) = f (xn ) By Taylor’s Theorem, we have 0 = f (ˆ) = f (xn − en ) x 1 = f (xn ) − en f (xn ) + e2 f (ξn ) 2 n (11) (12)

(9)

(10)

where ξn is a number between xn and x. A rearrangement of this equation ˆ yields 1 en f (xn ) − f (xn ) = f (ξn )e2 n 2 Putting this in (10) leads to en+1 = 1 f (ξn ) 2 1 f (ˆ) 2 x en ≈ en = Ce2 n 2 f (xn ) 2 f (ˆ) x (14) (13)

This equation tells us that en+1 is roughly a constant times e2 . This desirable n state of affairs is called quadratic convergence.

Uwe Wystup - Highlights of Computing

21

3.2

Heron’s Square Root Finder

• Goldman Sachs standard interview question: Find the square root of 17. • The Greek Engineer Heron who lived sometime between 100 B.C. and 100 A.D. had used the recursion xn+1 = to find the square root of R. • This is based on Newton’s method. • Taking R = 17 and starting with x0 = 4 we find x4 4.123105625617660549821409856 which is correct to 28 figures. = 1 2 xn + R xn (15)

3.3

Exercise: Divisions without Dividing

• Use Newton’s method to determine an algorithm that computes the reciprocal of a given number x, without ever performing any division. • apply your method to compute
1 19

exact to 8 decimal places.

4

Credit Cards

We follow An Introduction to the Mathematics of Money by Lovelock, Mendel and Wright [3]. • 9876 5432 1987 654 3 BIN cardholder ID checksum • BIN: Bank Identification Number • More on http://en.wikipedia.org/wiki/Credit_card_numbers • checksum: designed to protect against accidental errors, not malicious attacks. How? • Luhn algorithm (16)

Uwe Wystup - Highlights of Computing

22

4.1

The Luhn Algorithm

Hans Peter Luhn The Luhn algorithm or Luhn formula, also known as the modulus 10 or mod 10 algorithm, is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers and Canadian Social Insurance Numbers. It was created by IBM scientist Hans Peter Luhn and described in US Patent 2,950,048, filed on January 6, 1954, and granted on August 23, 1960.

Uwe Wystup - Highlights of Computing

23

9876 5432 1987 654 3 BIN cardholder ID checksum 9 ×2 ↓ 18 8 8 7 ×2 ↓ 14 6 6 5 ×2 ↓ 10 4 4 3 ×2 ↓ 6 2 2 1 ×2 ↓ 2

9

8 ×2 ↓

7

6 ×2 ↓

5

4 ×2 ↓

add up digits 82

9

16

7

12

5

8

Table 2: Example of the Luhn Algorithm Note: 18 counts as 1 + 8, i.e. count only the digits

9876 5432 1987 654 3 BIN cardholder ID checksum • Add the checksum 3 to the 82 and obtain 85. • If the new total is divisible by 10, then the credit card number has passed the validation test. • our number fails, whereas 9876 5432 1987 654 8 BIN cardholder ID checksum passes. • Note: Amex has one digit less and starts with the second digit.

Uwe Wystup - Highlights of Computing

24

4.2

Exercises

1. Implement the Luhn-Algorithm in Excel. 2. Apply the Luhn-Algorithm to your own credit card number. 3. In your group think of a credit card number and ask another group to verify it. 4. Does the Luhn Algorithm pick up any incorrect entry of a single digit? 5. Will the Luhn Algorithm pick up any incorrect transposition of adjacent digits?

5

Cryptography
1. The Inventors of the RSA-Algorithm 2. Method 3. Examples 4. Exercise

5.1

The Inventors of the RSA-Algorithm (1978)

Ron Rivest, Adi Shamir, and Leonard Adleman [5]

Uwe Wystup - Highlights of Computing

25

Ronald L. Rivest Andrew and Erna Viterbi Professor of Electrical Engineering and Computer Science in MIT’s Department of Electrical Engineering and Computer Science http://theory.lcs.mit.edu/~rivest/

Adi Shamir Paul and Marlene Borman Professor of Applied Mathematics at Weizmann Institute http://www.weizmann.ac.il/math/profile04/scientists/ shamir-prof04.html

Uwe Wystup - Highlights of Computing

26

Professor Leonard Adleman Department of Computer Science University of Southern California http://www.usc.edu/dept/molecular-science/fm-adleman.htm

5.2

Method

We follow Francis Litterio’ instructions on http://world.std.com/~franl/ crypto/rsa-guts.html. 1. Find P and Q, two large (e.g., 1024-bit) prime numbers. 2. Choose E ∈]1, P Q[, no prime factors in common with (P − 1)(Q − 1). 3. Compute D (the multiplicative inverse) such that DE = 1 mod (P − 1)(Q − 1). (Find an integer X which causes D = (X(P − 1)(Q − 1) + 1)/E to be an integer, then use that value of D.) 4. The encryption function is C = T E mod P Q, where C is the ciphertext (a positive integer), T is the plaintext (a positive integer). The message being encrypted, T , must be less than the modulus, P Q. 5. The decryption function is T = C D mod P Q, where C is the ciphertext (a positive integer), T is the plaintext (a positive integer).

Uwe Wystup - Highlights of Computing Your public key is the pair (P Q, E). Your private key is the number D (reveal it to no one). The product P Q is the modulus (often called N in the literature). E is the public exponent. D is the secret exponent. You can publish your public key freely, because there are no known easy methods of calculating D, P , or Q given only (P Q, E) (your public key). If P and Q are each 1024 bits long, the sun will burn out before the most powerful computers presently in existence can factor your modulus into P and Q.

27

5.3

Examples
P Q N = PQ P −1 Q−1 (P − 1)(Q − 1) 5 7 35 4 6 24 5 5 25 24 0 5 10 5 11 7 77 10 6 60 7 43 301 300 0 6 41 6 37 41 1517 36 40 1440 7 823 5761 5760 0 100 1062 100 61 53 3233 60 52 3120 17 2753 46801 46800 0 123 855 123

prime 1 prime 2 public modulus

public exponent inverse of E check check check plaintext encryption function decryption function

E D DE DE − 1 [DE − 1]/[(P − 1)(Q − 1)] T C = T E mod P Q T = C D mod P Q

Uwe Wystup - Highlights of Computing

28

5.4

Exercise

1. Set up an RSA tool in Excel/VBA and verify the examples. 2. Take two prime numbers P and Q between 100 and 200, e.g. from http: //primes.utm.edu and compute E and D. 3. Based on a plain text of your choice compute its ciphertext. 4. Give your public key and the ciphertext to the next group and determine the plaintext of another group.

6
6.1

Definitions
Prime Numbers

a number that can only be divided evenly by 1 and the number itself.

6.2

Modulus

For integers K, R and N the equation K = R mod N (17)

means that R is the remainder of the division of K by N or alternatively there exists an integer L such that N · L + R = K. (18)

Uwe Wystup - Highlights of Computing

29

7

Contact Information

Professor Dr. Uwe Wystup Ansua Dutta-Wystup Managing Directors MathFinance AG Mainluststraße 4 60329 Frankfurt am Main Germany Phone +49-700-MATHFINANCE More papers are available at http://www.mathfinance.com/wystup/papers.php These slides and handouts are available at http://www.mathfinance.com/seminars/vedic.php

References
[1] Burden, R. L. and Faires, J. D. (1993). Numerical analysis. PWS Publishing Company. [2] Datta, B. and Singh, A.N. (1962). History of Hindu Mathematics. Asia Publishing House, Calcutta. [3] Lovelock, D., Mendel, M. and Wright, A.L. (2007). An Introduction to the Mathematics of Money, Springer, New York. [4] Maharaja, Bharati Krsna Tirthaji (1992). Vedic Mathematics, Motilal Banarsidass Publishers Private Ltd, Delhi. [5] Rivest, R.L., Shamir, A. and Adleman, L.M. (1978). A Method for Obtaining Digital Signatures and Public-Key Cryptosystems. Communications of the ACM 21,2, 120–126. [6] Schonard, A. and Kokot, C. (2006). Der Mathekn¨ller. http://www. u matheknueller.de. [7] Williams, K.R. (2002). Vedic Mathematics - Teacher’s Manual. Advanced Level. Motilal Banarsidass Publishers Private Limited, Delhi. http://www.mlbd.com

Index
bank identification number (BIN), 21 BIN, 21 division, 11, 13 dual system, 3 duplex, 15 dvandvayoga, 15 ekadhika, 13 Heron’s Square Root Finder, 21 hexadecimal system, 3 Luhn algorithm, 22 Maya numerals, 3 modulus, 28 multiplication, 6 Newton’s Method, 18 numeral systems, 3 osculator, 13 prime number, 28 quadratic convergence, 20 RSA-Algorithm, 24 square root, 14 squares, 10 sutras, 5 vedas, 4

30

Sign up to vote on this title
UsefulNot useful