Schönhage–Strassen algorithm
The Schönhage–Strassen algorithm is an asymptotically fast multiplication algorithm for large integers, published by Arnold Schönhage and Volker Strassen in 1971. It works by recursively applying fast Fourier transform (FFT) over the integers modulo 2n+1. The run-time bit complexity to multiply two -digit numbers using the algorithm is  in big  notation. The Schönhage–Strassen algorithm was the asymptotically fastest multiplication method known from 1971 until 2007. It is asymptotically faster than older methods such as Karatsuba and Toom–Cook multiplication, and starts to outperform them in practice for numbers beyond about 10,000 to 100,000 decimal digits. In 2007, Martin Fürer published an algorithm with faster asymptotic complexity. In 2019, David Harvey and Joris van der Hoeven demonstrated that multi-digit multiplication has theoretical  complexity; however, their algorithm has constant factors which make it impossibly slow for any conceivable practical problem (see galactic algorithm). Applications of the Schönhage–Strassen algorithm include large computations done for their own sake such as the Great Internet Mersenne Prime Search and approximations of , as well as practical applications such as Lenstra elliptic curve factorization via Kronecker substitution, which reduces polynomial multiplication to integer multiplication. Description
Every number in base B, can be written as a polynomial:

Furthermore, multiplication of two numbers could be thought of as a product of two polynomials:

Because,for : ,
we have a convolution. By using FFT (Fast Fourier transform), used in original version rather than NTT, with convolution rule; we get

. That is; , where 
is the corresponding coefficient in fourier space. This can also be written as: fft(a * b) = fft(a) ● fft(b). We have the same coefficients due to linearity under Fourier transform, and because these polynomials 
only consist of one unique term per coefficient:

  and 

Convolution rule: 

We have reduced our convolution problem
to product problem, through FFT. By finding ifft (polynomial interpolation), for each , one get the desired coefficients. Algorithm uses divide and conquer strategy, to divide problem to subproblems. Convolution under mod N 
, where  and  in Schönhage–Strassen algorithm. By letting:

 and , where  is the n-th root

One see that:

. This mean, one can  use weight , and then multiply with  after. Instead of using weight; one can due to , in first step of recursion (when ), calculate :

In normal FFT, that operates over complex numbers, one would use:

However, FFT can also be used as a NTT (number theoretic transformation) in Schönhage–Strassen. This means that we have to use  that generate numbers in a finite field (for example ). A root of unity under a finite field , is an element a such that  or . For example , where  is a prime, 
gives . Notice that  in   and  in . For these candiadates,  under its finite field, and therefore act the way we want . Same FFT algorithms can still be used, though, as long as  is root of unity of a finite field. To find FFT/NTT transform, we do the following:

 
 

 

First product gives contribution to , for each . Second gives contribution to , due to  mod . To do the inverse:

 or  
depending on whether fft one use normalize data or not. One multiply by , to normailize fft data to a specific range, where  mod , where  is found using modular multiplicative inverse. Implementation details

Why N = 2 + 1  in mod N 

In Schönhage–Strassen algorithm, . One should think of this as a binary tree, where one have values in . By letting , one can for each  find all : One can group all  pairs into M different groups. Using  to group  pairs through convolution, is a classical problem in algorithms. For example: Let k be total income and  be mans income and  womans income; by using convolution, one can group   into   groups based on desired total income. Having this in mind,  help us to group  into  groups, for each group of subtasks in depth ; in tree with 

Notice that , for some L. This is Fermat number. When doing mod , we have something called Fermat ring. Because some Fermat numbers are Fermat primes, one can in some cases avoid calculations. There are other N that could have been used, of course, with same prime number advantages. By letting , one have the maximal number in a binary number with  bits. is a Mersenne number, that in some cases is a Mersenne prime. It is a natural candidate against Fermat number

In search of another N 

Doing several mod calculations against different , can be helpful when it comes to solving integer product. By using the Chinese remainder theorem, after splitting  into smaller different types of , one can find the answer of multiplication  

Fermat numbers and Mersenne numbers are just two types of numbers, in something called generalized Fermat Mersenne number (GSM); with formula:

In this formula;  is a Fermat number, and  is a Mersenne number. This formula can be used to generate sets of equations, that can be used in CRT (Chinese remainder theorem):

, where  is a number such that there exists a  where  , assuming 

Furthermore; , where  is an element that generates elements in  in a cyclic manner. If , where , then . How to choose K for a specific N 

Following formula helps one out, finding a proper  (number of groups to divide  bits into) given bit size  by calculating efficiency :

  is bit size (the one used in ) at outermost level. gives  groups of bits,  where . is found through  and  by finding the smallest , such that  

If one assume efficiency above 50%,  and  is very small compared to rest of formula; one get

This means: When something is very effective;  is bound above by  or asymptoticaly bound above by

Pseudocode

Following alogithm, the standard Modular Schönhage-Strassen Multiplication algorithm (with some optimizations), is found in overview through  

 T3MUL = Toom-Cook multiplication 
 SMUL  = Schönhage-Strassen multiplication
 Evaluate = FFT/IFFT

Further study 
For implemantion details, one can read the book Prime Numbers: A Computational Perspective. This variant differs somewhat from Schönhage's original method in that it exploits the discrete weighted transform to perform negacyclic convolutions more efficiently. Another source for detailed information is Knuth's The Art of Computer Programming. Optimizations

This section explains a number of important practical optimizations, when implementing Schönhage–Strassen. Use of other multiplications algorithm, inside algorithm 

Below a certain cutoff point, it's more efficient to use other multiplications algorithms, such as Toom–Cook multiplication. Square root of 2 trick 

The idea is to use  as root of unity of order  in finite field  ( it is a solution to equation ), when weighting values in NTT (number theoretic transformation) appraoch. It has been shown to save 10% in integer multiplication time. Granlund's trick 

By letting ; one can compute
 and . In combination with CRT (Chinese Remainder Theorem), to 
find exact values of multiplication

References

Computer arithmetic algorithms
Multiplication