- Number-theoretic transform
The number-theoretic transform (NTT) is similar to the
discrete Fourier transform , but operates withmodular arithmetic oninteger s instead ofcomplex number s.Definition
The discrete Fourier transform is given by
:
The number-theoretic transform operates on a sequence of "n" numbers, modulo a prime number "p" of the form "p"="ξn"+1, where "ξ" can be any positive integer.
The number is replaced by a number where "ω" is a "primitive root" of "p", a number where the lowest positive integer "n" such that "ω""n"=1 is "n"=p-1. There should be plenty of "ω" which fit this condition. Note that both and "ω""ξ" raised to the power of "n" are equal to 1 (mod p), all lesser positive powers not equal to 1.
The number-theoretic transform is then given by
:
The inverse number-theoretic transform is given by
:
Note that "ω"p-1-"ξ"="ω"-"ξ", the reciprocal of "ω""ξ", and "n""p"-2="n"-1, the reciprocal of "n". (mod p)
Properties
Most of the important attributes of the DFT, including the inverse transform, the
convolution theorem , and mostfast Fourier transform (FFT) algorithms, depend only on the property that the kernel of the transform, , is a primitive root of unity. Since that same property holds for "ω""ξ", it immediately follows that the NTT has the same useful attributes — the proofs are identical.In particular, the applicability of FFT algorithms to compute the NTT, combined with the convolution theorem, mean that the NTT gives an efficient way to compute exact
convolution s of integer sequences. While the DFT can perform the same task, it is susceptible toround-off error in finite-precisionfloating point arithmetic; the NTT has no round-off because it deals purely with integers that can be exactly represented, althougharithmetic overflow is still a possibility.Proof of inverse NTT
More explicitly, the inverse works because is "n" for z=1 and 0 for all other "z" where "z""n"=1. A proof of this (should work for any
division algebra ) is:
: (subtracting "z""n"=1)
: (dividing both sides)
If "z"=1 then we could trivially see that . If "z"≠1 then the right side must be false to avoid a contradiction.
It is now straightforward to complete the proof. We take the putative inverse transform of the transform.
:
:
:: (since "ω""ξn"=1)
:
: (by
Fermat's little theorem )ee also
*
Gauss sum
*Convolution
*Multiplication algorithm External links
* [http://www.apfloat.org/ntt.html Site which (hopefully) says the same as this article]
Wikimedia Foundation. 2010.