by nickcw · 2y ago · 0 comments
So suppose you have a 1000 digit number. You then take each digit and use it as the coefficient of a 1000 element polynomial. You can then multiply these polynomials together using the fft method as described in the article. To convert the result back to a number you need to do the carries. So if an element is bigger than 10 you carry the excess to the next digit. You then take the coefficients and turn them into numbers.
That's the basic idea. There is some subtlety I've glossed over due to precision needed for the carries and to be sure that rounding the fft result to the nearest integer is correct. That is the way big number multiplication is done in GMP which is the leading Library for this sort of thing.
All of this happens in a field of an elliptic curve so the complexity reduction is greatly appreciated.
https://gmplib.org/manual/Multiplication-Algorithms
GMP has lots of other methods in between schoolbook multiplication and FFT multiplication. A nice one is Karatsuba multiplication which is very easy to understand and delivers O(n^1.58) rather than O(n^2) performance. Python uses this method for multiplying large numbers together
http://gmplib.org/devel/log.i7.1024.png
More context and explanation can be found at: http://gmplib.org/devel/
BTW, I like Bernstein's survey of different multiplication algorithms at
https://cr.yp.to/papers/m3.pdf
(there is a unifying theme about using ring isomorphisms to explain many of the "standard" routines.)
https://hal.science/hal-02070778v2/document
A pop-sci description can be found at
https://theconversation.com/weve-found-a-quicker-way-to-mult...