Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Sieve of Eratosthenes wikipedia , lookup
Lateral computing wikipedia , lookup
Hardware random number generator wikipedia , lookup
Post-quantum cryptography wikipedia , lookup
Algorithm characterizations wikipedia , lookup
Fast Fourier transform wikipedia , lookup
Computational complexity theory wikipedia , lookup
Factorization of polynomials over finite fields wikipedia , lookup
Integer Multiplication Algorithm Learning Objectives By the end of this module, the learner will be able to: 1. Apply the divide and conquer paradigm to solve the Integer Multiplication problem efficiently. 2. Get an insight about techniques to increase the efficiency of solving the Integer multiplication problem. Time Required 2 hours (approx) Introduction It’s obvious where the Karatsuba algorithm can be used. It is very efficient when it comes to integer multiplication, but that isn’t its only advantage. It is often used for polynomial multiplications. Andrey Kolmogorov is one of the brightest Russian mathematicians of the 20th century. In 1960, during a seminar, Kolmogorov stated that two n-digit numbers can’t be multiplied with less than n2 multiplications! Only a week later a 23-year young student called Anatolii Alexeevitch Karatsuba proved that the multiplication of two ndigit numbers can be computed with n ^ log(3) multiplications with an ingenious divide and conquer approach. Given two numbers A and B in base ‘r’ find A*B. Let the length of the two numbers be equal to n. A Naive Approach is to follow the process we studied in school. One by one take all bits of second number and multiply it with all bits of first number. Finally add all the multiplications. This algorithm takes O (n2) time. For most of the time we will be considering a computational model where individual elements in the matrices are viewed as “small” and can be added or multiplied in constant time. Today however, we talk about an algorithm for multiplying very large numbers.Say, we want to multiply two n-bit numbers: for example, 41 × 42 (or, in binary, 101001 × 101010). According to the definition of what it means to multiply, what we are looking for is the result of adding 41 to itself 42 times (or vice versa). You could imagine actually computing the answer that way (i.e., performing 41 additions), which would be correct but not particularly efficient. If we used this approach to multiply two n-bit numbers, we would be making Θ(2n) additions. This is exponential in n even without counting the number of steps needed to perform each addition. And, in general, exponential is bad. A better way to multiply is to do what we learned in grade school: More formally, we scan the second number right to left, and every time we see a 1, we add a copy of the first number, shifted by the appropriate number of bits, to our total.Each addition takes O(n) time, and we perform at most n additions, which means the total running time here is O(n2). So, this is a simple example where even though the problem is defined “algorithmically”, using the definition is not the best way of solving the problem. Let us assume n is even. We then represent the Numbers A and B as follows A=al*10n/2 + ar [al and ar contain leftmost and rightmost n/2 bits of A] B=bl*10n/2 + br [bl and br contain leftmost and rightmost n/2 bits of B] Thus, A*B = (al* + ar)*(bl* + br) = al*bl* + (ar*bl + br*al)* + ar*br It is possible to perform multiplication of large numbers in (many) fewer operations than the usual brute-force technique of "long multiplication." As discovered by Karatsuba (Karatsuba and Ofman 1962), multiplication of two -digit numbers can be done with a less bit complexity. It’s obvious where the Karatsuba algorithm can be used. It is very efficient when it comes to integer multiplication, but that isn't its only advantage. It is often used for polynomial multiplications.