Presentation is loading. Please wait.

Presentation is loading. Please wait.

Complexity of Computations Nicholas Tran Department of Mathematics & Computer Science Santa Clara University Santa Clara, CA 95053 USA.

Similar presentations


Presentation on theme: "Complexity of Computations Nicholas Tran Department of Mathematics & Computer Science Santa Clara University Santa Clara, CA 95053 USA."— Presentation transcript:

1 Complexity of Computations Nicholas Tran Department of Mathematics & Computer Science Santa Clara University Santa Clara, CA 95053 USA

2 How fast can computers add two integers ? 1 2 3 + 4 5 6 --------- 5 7 9

3 Running Time is measured... In terms of basic operations (digit addition) As a function of input size (number of digits)

4 A(n) = n (digit additions) a n a n-1 a n-2... a 2 a 1 + b n b n-1 b n-2... b 2 b 1 --------------------------------------- c n+1 c n c n-1 c n-2... c 2 c 1

5 Linear Running Time is FAST! Assume: 3GHz processor (3 billion cycles / second) One basic operation = 10 cycles 64-bit words (19 decimal digits) Can add 4.7 million pairs of 64-bit integers in one second!

6 Is Linear Time Optimal ? Yes! Every bit must be examined

7 How fast can computers multiply two integers ? 1 2 * 3 4 -------- 4 8 3 6 4 0 8

8 M(n) = n 2 (digit mults) + (n-1)n (digit additions) a n a n-1 a n-2... a 2 a 1 * b n b n-1 b n-2... b 2 b 1 ---------------------------------------

9 Quadratic Running Time is OK Assume: 3GHz processor (3 billion cycles / second) One basic operation = 10 cycles Can multiply 300 pairs of 1024-bit integers in one second.

10 Is Quadratic Time optimal ? No! Divide-and-conquer method: n 1.585 Fast-Fourier-Transform: n log n

11 Divide and Conquer Multiplication A 1 a n... a 1+n/2 a n/2... a 1 A 0 B 1 b n... b 1+n/2 b n/2... b 1 B 0 A*B = 2 n (A 1 *B 1 ) + 2 n/2 [(A 1 – A 0 )*(B 0 – B 1 ) + A 1 *B 1 + A 0 *B 0 ] + A 0 *B 0

12 Running Time M(n) = 3M(n/2) = 3*(3M(n/4)) = 3*3*(3M(n/8)) =... = 3 lg n = n lg 3 = n 1.585...

13 Open Question Linear-time algorithm for integer multiplication ?

14 How fast can computers multiply two matrices ? 1 2 5 6 19 22 * = 3 4 7 8 36 40

15 MT(n) = n 3 (multiplications) Result matrix has n 2 entries Each entry requires n multiplications

16 Is Cubic Time optimal ? No! Divide-and-conquer method: n 2.8074 Fastest known: n 2.376

17 Open Question Quadratic-time algorithm for matrix multiplication ?

18 How fast can computers compute b x ? 207 314 = 163941337332542421506559015723347759364300068397756479870218390908602100383\ 07922727887209064687385169802330113993715822472651871750525058759656611\ 33524136520376084888852214059673269428533014335800256092944711066046124\ 65720634680059676515229653689770006451644184755542774816379633924627617\ 05099174019255538743584629999826446047309939592097350115722833385636445\ 63886481013473075657995735436727794479189654529537393093545923092137017\ 52102655263222045614392981857588240904150531584994663864142668575382184\ 77683376171973571372801939885320527927087749711039139096117682810252441\ 30411871017236729965957901414498677146321719899287248980868996796413073\ 45380396119706515352607745909505485585157609318105039969986657456119601\ 41747323092449

19 Naïve algorithm: x multiplications b x = b*b*...*b (x times)

20 Better algorithm: 2n multiplications (n=lg x) b 21 = b 16+4+1 = b 16 b 4 b 1 b b 2 = b*b b 4 = b 2 * b 2 b 8 = b 4 * b 4 b 16 = b 8 * b 8

21 How fast can computers find gcd(a,b) ? Greatest common divisor of 9 and 6 is 3

22 Naïve method: min(a,b) divisions Gcd(9, 6): 6 divides 6 but not 9 5 does not divide 6 4 does not divide 6 3 divides 6 AND 9

23 Euclidean Algorithm: 5*lg min(a, b) gcd(a, b) = gcd(b, a mod b) gcd(1357911,361) = gcd(361, 190) = gcd(190, 171) = gcd(171, 19) = gcd(19, 0) = 19

24 gcd(a, b) by factoring into primes 9 = 2 0 * 3 2 6 = 2 1 * 3 1 gcd(9, 6) = 2 0 * 3 1

25 How fast can computers recognize primes ? Isprime(11) = true Isprime(314159) = true Isprime(27183) = fase

26 Naïve method: √x divisions Theorem: if x = ab, then either a or b is at most √x

27 Too slow for large x! Largest known prime: 2 32482657 – 1 Would take 2 16241272 ~ 10 4889109 years (age of universe ~ 10 10 years)

28 Major Breakthrough Agrawal, Kayal, Saxena published an algorithm in 2004 with running time (lg x) 6 Would take 10 29 years on the largest known prime!

29 In practice... Probabilistic algorithm (Rabin) Very fast [(lg x) 2] but may make mistake Would take 40 days on the largest known prime

30 How fast can computers factor integers ? 3141592653589793 = 13 * 241 * 1002742628021

31 Open Question Fastest known algorithm for factoring integers is faster than x but slower than lg x Is there a fast algorithm for factoring integers ?

32 Major Breakthrough Shor published a (lg x) 3 method for quantum computers in 2001

33 RSA Cryptography Invented by Rivest, Shamir, Adleman in 1978 Seems unbreakable if there are no fast methods for integer factoring

34 How RSA works I put on my website two integers (n, e) n is the product of two secret big primes p, q e is chosen so that gcd(e, (p-1)(q-1)) = 1 I compute d so that de = 1 + multiple of (p-1)(q-1)

35 To send a message x You get (n, e) from my website and send x e (mod n) I decrypt by computing (x e ) d (mod n) = x Unless you can factor n = pq, it seems hard to find d

36 Example (Stinson) I put on my website (11413, 3533) 11413 = 101 * 113 gcd(3533, (100*112)) = 1 d = 6597 6597 * 3533 = 1 (mod 11200)

37 Example (ctd.) To send me 9726, you compute 9726 3533 (mod 11413) = 5761 To decode I compute 5761 6597 (mod 11413) = 9726

38 Exploiting Hardness of Pattern Recognition

39 Even Harder Problems Traveling Salesman: shortest route starting from San Jose through n cities Partition: divide a set of n people into two groups, so that the total weight of each group is identical

40 NP-hard Problems Solutions are hard to find but easy to check A fast solution to any of these problems would yield a fast solution to integer factoring A one-million dollar prize is currently offered to a resolution of this issue

41 Summary


Download ppt "Complexity of Computations Nicholas Tran Department of Mathematics & Computer Science Santa Clara University Santa Clara, CA 95053 USA."

Similar presentations


Ads by Google