complexity of computations nicholas tran department of mathematics & computer science santa...
DESCRIPTION
Running Time is measured... In terms of basic operations (digit addition) As a function of input size (number of digits)TRANSCRIPT
Complexity of Computations
Nicholas TranDepartment of Mathematics & Computer
ScienceSanta Clara UniversitySanta Clara, CA 95053
USA
How fast can computers add two integers ? 1 2 3
+ 4 5 6
---------
5 7 9
Running Time is measured ... In terms of basic operations (digit
addition) As a function of input size
(number of digits)
A(n) = n (digit additions) an an-1 an-2 ... a2 a1
+ bn bn-1 bn-2 ... b2 b1
---------------------------------------
cn+1 cn cn-1 cn-2 ... c2 c1
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!
Is Linear Time Optimal ? Yes! Every bit must be examined
How fast can computers multiply two integers ? 1 2
* 3 4
--------
4 8
3 6
4 0 8
M(n) = n2 (digit mults) + (n-1)n (digit additions) an an-1 an-2 ... a2
a1
* bn bn-1 bn-2 ... b2 b1
---------------------------------------
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.
Is Quadratic Time optimal ? No! Divide-and-conquer method: n1.585
Fast-Fourier-Transform: n log n
Divide and Conquer Multiplication
A1 an ... a1+n/2 an/2 ... a1 A0
B1 bn ... b1+n/2 bn/2 ... b1 B0
A*B = 2n(A1*B1) + 2n/2[(A1 – A0)*(B0 – B1) + A1*B1 + A0*B0] + A0*B0
Running TimeM(n) = 3M(n/2) = 3*(3M(n/4)) = 3*3*(3M(n/8)) = ... = 3lg n = nlg 3 = n1.585...
Open Question Linear-time algorithm for integer
multiplication ?
How fast can computers multiply two matrices ? 1 2 5 6 19 22 * = 3 4 7 8 36 40
MT(n) = n3 (multiplications) Result matrix has n2 entries Each entry requires n
multiplications
Is Cubic Time optimal ? No! Divide-and-conquer method: n2.8074
Fastest known: n2.376
Open Question Quadratic-time algorithm for matrix
multiplication ?
How fast can computers compute bx ? 207314 =
163941337332542421506559015723347759364300068397756479870218390908602100383\ 07922727887209064687385169802330113993715822472651871750525058759656611\
33524136520376084888852214059673269428533014335800256092944711066046124\ 65720634680059676515229653689770006451644184755542774816379633924627617\ 05099174019255538743584629999826446047309939592097350115722833385636445\ 63886481013473075657995735436727794479189654529537393093545923092137017\ 52102655263222045614392981857588240904150531584994663864142668575382184\ 77683376171973571372801939885320527927087749711039139096117682810252441\ 30411871017236729965957901414498677146321719899287248980868996796413073\ 45380396119706515352607745909505485585157609318105039969986657456119601\ 41747323092449
Naïve algorithm: x multiplications bx = b*b*...*b (x times)
Better algorithm: 2n multiplications (n=lg x)b21 = b16+4+1 = b16b4b1
bb2 = b*bb4 = b2 * b2
b8 = b4 * b4
b16 = b8 * b8
How fast can computers find gcd(a,b) ? Greatest common divisor of 9 and 6
is 3
Naïve method: min(a,b) divisionsGcd(9, 6):
6 divides 6 but not 95 does not divide 64 does not divide 63 divides 6 AND 9
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
gcd(a, b) by factoring into primes
9 = 20 * 32
6 = 21 * 31
gcd(9, 6) = 20 * 31
How fast can computers recognize primes ? Isprime(11) = true Isprime(314159) = true Isprime(27183) = fase
Naïve method: √x divisionsTheorem: if x = ab, then either a or b is at most √x
Too slow for large x! Largest known prime: 232482657 – 1
Would take 216241272 ~ 104889109 years (age of universe ~ 1010 years)
Major Breakthrough Agrawal, Kayal, Saxena published
an algorithm in 2004 with running time
(lg x)6
Would take 1029 years on the largest known prime!
In practice... Probabilistic algorithm (Rabin) Very fast [(lg x)2] but may make
mistake Would take 40 days on the largest
known prime
How fast can computers factor integers ? 3141592653589793 = 13 * 241 * 1002742628021
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 ?
Major Breakthrough Shor published a (lg x)3 method for
quantum computers in 2001
RSA Cryptography Invented by Rivest, Shamir,
Adleman in 1978 Seems unbreakable if there are no
fast methods for integer factoring
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)
To send a message x You get (n, e) from my website and send xe (mod n)
I decrypt by computing (xe)d (mod n) = x Unless you can factor n = pq, it seems
hard to find d
Example (Stinson) I put on my website (11413, 3533) 11413 = 101 * 113 gcd(3533, (100*112)) = 1 d = 6597 6597 * 3533 = 1 (mod 11200)
Example (ctd.) To send me 9726, you compute 97263533 (mod 11413) = 5761 To decode I compute 57616597 (mod 11413) =
9726
Exploiting Hardness of Pattern Recognition
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
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
Summary