How fast can you multiply really big numbers?

Using the algorithm you learned in elementary school, it takes O(n²) operations to multiply two n digit numbers.

But for large enough numbers it pays to carry out multiplication very differently, using FFTs.

If you’re multiplying integers with tens of thousands of decimal digits, the most efficient algorithm is the Schönhage-Strassen, which takesO(n log n  log log n)operations.

For smaller numbers, another algorithm, such as Karatsuba’s algorithm, might be faster.

And for impractically large numbers, Fürer’s algorithm is faster.

What is impractically large?.Let’s say a number is impractically large if storing it requires more than a billion dollars worth of RAM.

If I did my back-of-the-envelop math correctly, you can buy enough RAM to store about 257 bits for about a billion dollars.

The Schönhage-Strassen algorithm is more efficient than Fürer’s algorithm for numbers with less than 264 bits.

Related post: How fast can you multiply matrices?.

. More details

Leave a Reply