The Cooley–Tukey algorithm, named after
J. W. Cooley and
John Tukey
John Wilder Tukey (; June 16, 1915 – July 26, 2000) was an American mathematician and statistician, best known for the development of the fast Fourier Transform (FFT) algorithm and box plot. The Tukey range test, the Tukey lambda distributi ...
, is the most common
fast Fourier transform
A fast Fourier transform (FFT) is an algorithm that computes the discrete Fourier transform (DFT) of a sequence, or its inverse (IDFT). A Fourier transform converts a signal from its original domain (often time or space) to a representation in ...
(FFT) algorithm. It re-expresses the
discrete Fourier transform
In mathematics, the discrete Fourier transform (DFT) converts a finite sequence of equally-spaced Sampling (signal processing), samples of a function (mathematics), function into a same-length sequence of equally-spaced samples of the discre ...
(DFT) of an arbitrary
composite size
in terms of ''N''
1 smaller DFTs of sizes ''N''
2,
recursively, to reduce the computation time to O(''N'' log ''N'') for highly composite ''N'' (
smooth number
In number theory, an ''n''-smooth (or ''n''-friable) number is an integer whose prime factors are all less than or equal to ''n''. For example, a 7-smooth number is a number in which every prime factor is at most 7. Therefore, 49 = 72 and 15750 = 2 ...
s). Because of the algorithm's importance, specific variants and implementation styles have become known by their own names, as described below.
Because the Cooley–Tukey algorithm breaks the DFT into smaller DFTs, it can be combined arbitrarily with any other algorithm for the DFT. For example,
Rader's or
Bluestein's algorithm can be used to handle large prime factors that cannot be decomposed by Cooley–Tukey, or the
prime-factor algorithm can be exploited for greater efficiency in separating out
relatively prime
In number theory, two integers and are coprime, relatively prime or mutually prime if the only positive integer that is a divisor of both of them is 1. Consequently, any prime number that divides does not divide , and vice versa. This is equiv ...
factors.
The algorithm, along with its recursive application, was invented by
Carl Friedrich Gauss
Johann Carl Friedrich Gauss (; ; ; 30 April 177723 February 1855) was a German mathematician, astronomer, geodesist, and physicist, who contributed to many fields in mathematics and science. He was director of the Göttingen Observatory and ...
. Cooley and Tukey independently rediscovered and popularized it 160 years later.
History
This algorithm, including its recursive application, was invented around 1805 by
Carl Friedrich Gauss
Johann Carl Friedrich Gauss (; ; ; 30 April 177723 February 1855) was a German mathematician, astronomer, geodesist, and physicist, who contributed to many fields in mathematics and science. He was director of the Göttingen Observatory and ...
, who used it to interpolate the trajectories of the
asteroid
An asteroid is a minor planet—an object larger than a meteoroid that is neither a planet nor an identified comet—that orbits within the Solar System#Inner Solar System, inner Solar System or is co-orbital with Jupiter (Trojan asteroids). As ...
s
Pallas
Pallas may refer to:
Astronomy
* 2 Pallas asteroid
** Pallas family, a group of asteroids that includes 2 Pallas
* Pallas (crater), a crater on Earth's moon
Mythology
* Pallas (Giant), a son of Uranus and Gaia, killed and flayed by Athena
* Pa ...
and
Juno, but his work was not widely recognized (being published only posthumously and in
Neo-Latin
Neo-LatinSidwell, Keith ''Classical Latin-Medieval Latin-Neo Latin'' in ; others, throughout. (also known as New Latin and Modern Latin) is the style of written Latin used in original literary, scholarly, and scientific works, first in Italy d ...
).
[Heideman, M. T., D. H. Johnson, and C. S. Burrus,]
Gauss and the history of the fast Fourier transform
" IEEE ASSP Magazine, 1, (4), 14–21 (1984) Gauss did not analyze the asymptotic computational time, however. Various limited forms were also rediscovered several times throughout the 19th and early 20th centuries.
[ FFTs became popular after James Cooley of ]IBM
International Business Machines Corporation (using the trademark IBM), nicknamed Big Blue, is an American Multinational corporation, multinational technology company headquartered in Armonk, New York, and present in over 175 countries. It is ...
and John Tukey
John Wilder Tukey (; June 16, 1915 – July 26, 2000) was an American mathematician and statistician, best known for the development of the fast Fourier Transform (FFT) algorithm and box plot. The Tukey range test, the Tukey lambda distributi ...
of Princeton published a paper in 1965 reinventing[ the algorithm and describing how to perform it conveniently on a computer.]
Tukey reportedly came up with the idea during a meeting of President Kennedy's Science Advisory Committee discussing ways to detect nuclear-weapon tests in the Soviet Union
The Union of Soviet Socialist Republics. (USSR), commonly known as the Soviet Union, was a List of former transcontinental countries#Since 1700, transcontinental country that spanned much of Eurasia from 1922 until Dissolution of the Soviet ...
by employing seismometers located outside the country. These sensors would generate seismological time series. However, analysis of this data would require fast algorithms for computing DFTs due to the number of sensors and length of time. This task was critical for the ratification of the proposed nuclear test ban so that any violations could be detected without need to visit Soviet facilities. Another participant at that meeting, Richard Garwin of IBM, recognized the potential of the method and put Tukey in touch with Cooley. However, Garwin made sure that Cooley did not know the original purpose. Instead, Cooley was told that this was needed to determine periodicities of the spin orientations in a 3-D crystal of helium-3
Helium-3 (3He see also helion) is a light, stable isotope of helium with two protons and one neutron. (In contrast, the most common isotope, helium-4, has two protons and two neutrons.) Helium-3 and hydrogen-1 are the only stable nuclides with ...
. Cooley and Tukey subsequently published their joint paper, and wide adoption quickly followed due to the simultaneous development of Analog-to-digital converter
In electronics, an analog-to-digital converter (ADC, A/D, or A-to-D) is a system that converts an analog signal, such as a sound picked up by a microphone or light entering a digital camera, into a Digital signal (signal processing), digi ...
s capable of sampling at rates up to 300 kHz.
The fact that Gauss had described the same algorithm (albeit without analyzing its asymptotic cost) was not realized until several years after Cooley and Tukey's 1965 paper.[ Their paper cited as inspiration only the work by I. J. Good on what is now called the prime-factor FFT algorithm (PFA);][ although Good's algorithm was initially thought to be equivalent to the Cooley–Tukey algorithm, it was quickly realized that PFA is a quite different algorithm (working only for sizes that have ]relatively prime
In number theory, two integers and are coprime, relatively prime or mutually prime if the only positive integer that is a divisor of both of them is 1. Consequently, any prime number that divides does not divide , and vice versa. This is equiv ...
factors and relying on the Chinese remainder theorem
In mathematics, the Chinese remainder theorem states that if one knows the remainders of the Euclidean division of an integer ''n'' by several integers, then one can determine uniquely the remainder of the division of ''n'' by the product of thes ...
, unlike the support for any composite size in Cooley–Tukey).
The radix-2 DIT case
A radix-2 decimation-in-time (DIT) FFT is the simplest and most common form of the Cooley–Tukey algorithm, although highly optimized Cooley–Tukey implementations typically use other forms of the algorithm as described below. Radix-2 DIT divides a DFT of size ''N'' into two interleaved DFTs (hence the name "radix-2") of size ''N''/2 with each recursive stage.
The discrete Fourier transform (DFT) is defined by the formula:
:
where is an integer ranging from 0 to .
Radix-2 DIT first computes the DFTs of the even-indexed inputs
and of the odd-indexed inputs , and then combines those two results to produce the DFT of the whole sequence. This idea can then be performed recursively to reduce the overall runtime to O(''N'' log ''N''). This simplified form assumes that ''N'' is a power of two
A power of two is a number of the form where is an integer, that is, the result of exponentiation with number 2, two as the Base (exponentiation), base and integer as the exponent. In the fast-growing hierarchy, is exactly equal to f_1^ ...
; since the number of sample points ''N'' can usually be chosen freely by the application (e.g. by changing the sample rate or window, zero-padding, etcetera), this is often not an important restriction.
The radix-2 DIT algorithm rearranges the DFT of the function into two parts: a sum over the even-numbered indices and a sum over the odd-numbered indices :
:
One can factor a common multiplier out of the second sum, as shown in the equation below. It is then clear that the two sums are the DFT of the even-indexed part and the DFT of odd-indexed part of the function . Denote the DFT of the ''E''ven-indexed inputs by and the DFT of the ''O''dd-indexed inputs by and we obtain:
:
Note that the equalities hold for ,
but the crux is that and are calculated in this way for only.
Thanks to the periodicity of the complex exponential, is also obtained from and :
:
We can rewrite and as:
:
This result, expressing the DFT of length ''N'' recursively in terms of two DFTs of size ''N''/2, is the core of the radix-2 DIT fast Fourier transform. The algorithm gains its speed by re-using the results of intermediate computations to compute multiple DFT outputs. Note that final outputs are obtained by a +/− combination of and , which is simply a size-2 DFT (sometimes called a butterfly
Butterflies are winged insects from the lepidopteran superfamily Papilionoidea, characterized by large, often brightly coloured wings that often fold together when at rest, and a conspicuous, fluttering flight. The oldest butterfly fossi ...
in this context); when this is generalized to larger radices below, the size-2 DFT is replaced by a larger DFT (which itself can be evaluated with an FFT).
This process is an example of the general technique of divide and conquer algorithms; in many conventional implementations, however, the explicit recursion is avoided, and instead one traverses the computational tree in breadth-first fashion.
The above re-expression of a size-''N'' DFT as two size-''N''/2 DFTs is sometimes called the Danielson– Lanczos lemma, since the identity was noted by those two authors in 1942 (influenced by Runge's 1903 work[). They applied their lemma in a "backwards" recursive fashion, repeatedly ''doubling'' the DFT size until the transform spectrum converged (although they apparently didn't realize the linearithmic .e., order ''N'' log ''N''asymptotic complexity they had achieved). The Danielson–Lanczos work predated widespread availability of mechanical or electronic computers and required manual calculation (possibly with mechanical aids such as ]adding machine
An adding machine is a class of mechanical calculator, usually specialized for bookkeeping calculations. Consequently, the earliest adding machines were often designed to read in particular currencies. Adding machines were ubiquitous office ...
s); they reported a computation time of 140 minutes for a size-64 DFT operating on real inputs to 3–5 significant digits. Cooley and Tukey's 1965 paper reported a running time of 0.02 minutes for a size-2048 complex DFT on an IBM 7094 (probably in 36-bit single precision
Single-precision floating-point format (sometimes called FP32 or float32) is a computer number format, usually occupying 32 bits in computer memory; it represents a wide dynamic range of numeric values by using a floating radix point.
A floa ...
, ~8 digits).[ Rescaling the time by the number of operations, this corresponds roughly to a speedup factor of around 800,000. (To put the time for the hand calculation in perspective, 140 minutes for size 64 corresponds to an average of at most 16 seconds per floating-point operation, around 20% of which are multiplications.)
]
Pseudocode
In pseudocode
In computer science, pseudocode is a description of the steps in an algorithm using a mix of conventions of programming languages (like assignment operator, conditional operator, loop) with informal, usually self-explanatory, notation of actio ...
, the below procedure could be written:
''X''0,...,''N''−1 ← ditfft2(''x'', ''N'', ''s''): ''DFT of (x''0, ''xs'', ''x''2''s'', ..., ''x''(''N''-1)''s''):
if ''N'' = 1 then
''X''0 ← ''x''0 ''trivial size-1 DFT base case''
else
''X''0,...,''N''/2−1 ← ditfft2(''x'', ''N''/2, 2''s'') ''DFT of (x''0, ''x''2''s'', ''x''4''s'', ..., ''x''(''N''-2)''s'')
''XN''/2,...,''N''−1 ← ditfft2(''x''+s, ''N''/2, 2''s'') ''DFT of (xs'', ''xs''+2''s'', ''xs''+4''s'', ..., ''x''(''N''-1)''s'')
for k = 0 to (N/2)-1 do ''combine DFTs of two halves:''
p ← ''Xk''
q ← exp(−2π''i''/''N'' ''k'') ''Xk''+''N''/2
''Xk'' ← p + q
''Xk''+''N''/2 ← p − q
end for
end if
Here, ditfft2
(''x'',''N'',1), computes ''X''=DFT(''x'') out-of-place by a radix-2 DIT FFT, where ''N'' is an integer power of 2 and ''s''=1 is the stride of the input ''x'' array. ''x''+''s'' denotes the array starting with ''xs''.
(The results are in the correct order in ''X'' and no further bit-reversal permutation is required; the often-mentioned necessity of a separate bit-reversal stage only arises for certain in-place algorithms, as described below.)
High-performance FFT implementations make many modifications to the implementation of such an algorithm compared to this simple pseudocode. For example, one can use a larger base case than ''N''=1 to amortize the overhead of recursion, the twiddle factor
A twiddle factor, in fast Fourier transform (FFT) algorithms, is any of the trigonometric constant coefficients that are multiplied by the data in the course of the algorithm. This term was apparently coined by Gentleman & Sande in 1966, and has ...
s