Content deleted Content added
Pat power11 (talk | contribs) |
|||
Line 367:
=== Fourier transform methods ===
[[File:Integer multiplication by FFT.svg|thumb|350px|Demonstration of multiplying 1234 × 5678 = 7006652 using fast Fourier transforms (FFTs). [[Number-theoretic transform]]s in the integers modulo 337 are used, selecting 85 as an 8th root of unity. Base 10 is used in place of base 2<sup>''w''</sup> for illustrative purposes.]]
The basic idea
: <math>a=\sum_{i=0}^m {a_i 2^{wi}
We look at these numbers as polynomials in ''x'', where ''x = 2^w'', to get,
We can then say that▼
: <math>
: <math>ab=\sum_{i=0}^m \sum_{j=0}^m a_i b_j x^{(i+j)} = \sum_{k=0}^{2m} \sum_{i=0}^k a_i b_{k-i} x^{k} = \sum_{k=0}^{2m} c_k x^{k} </math>
by setting ''b''<sub>''j''</sub> = 0 and ''a''<sub>''i''</sub> = 0 for ''j'', ''i'' > ''m'', ''k'' = ''i'' + ''j'' and {''c''<sub>''k''</sub>} as the [[convolution]] of {''a''<sub>''i''</sub>} and {''b''<sub>''j''</sub>}. Using the [[convolution theorem]] ''ab'' can be computed by
Line 383 ⟶ 387:
Another way to describe this process is forming polynomials whose coefficients are the digits of the inputs (in base 2<sup>''w''</sup>), multiplying them rapidly using convolution by FFT, then extracting the coefficients of the result polynomial and performing carrying.
The
Using [[number-theoretic transform]]s instead of [[discrete Fourier transform]]s avoids [[rounding error]] problems by using modular arithmetic instead of [[floating point|floating-point]] arithmetic. In order to apply the factoring which enables the FFT to work, the length of the transform must be factorable to small primes, and must be a factor of ''N''-1, where ''N'' is the field size. In particular, calculation using a Galois Field GF(''k''<sup>2</sup>), where ''k'' is a [[Mersenne Prime]], allows the use of a transform sized to a power of 2; e.g. ''k'' = 2<sup>31</sup>-1 supports transform sizes up to 2<sup>32</sup>.
|