Short answer: The Cooley-Tukey FFT computes a discrete Fourier transform of length n = 2^m by splitting it into the even indices and the odd indices, each a transform of length n/2, then combining them with twiddle factors ω^k. The recurrence T(n) = 2T(n/2) + O(n) solves to O(n log n) arithmetic operations. A direct DFT is O(n²). The same split works for any highly composite length. Radix-2 is the form to implement first.
What the problem actually asks
The DFT sums x[j] · ω^{jk} for every frequency k, with ω = e^{−2πi/n}. Each of the n frequencies costs n multiplications if computed alone. Even and odd parts share subtransforms. The even subtransform is the DFT of x[0], x[2], …. The odd subtransform is the DFT of x[1], x[3], …. Frequency k and frequency k+n/2 reuse those two results with a sign change on the odd branch.
The bit-reversal permutation of an iterative in-place FFT is the bookkeeping of this recursion, not a separate mathematical step. An out-of-place recursive implementation can skip the permutation by writing results into the right half of the output.
What the algorithm guarantees
The algorithm returns the same numbers as the definition of the DFT, up to floating-point rounding. Time is Θ(n log n) complex operations for radix-2. Extra memory is O(n) for an out-of-place transform, or O(1) extra plus the bit reversal for a careful in-place transform. Inverse FFT uses the conjugate twiddle, or ω^{+2πi/n}, and divides by n. Forgetting the division returns n times the original signal.
A length that is not a power of two can be zero-padded to the next power, which changes the frequency grid, or factored into mixed radices. Convolution of two arrays is a pointwise product of their DFTs, with both arrays zero-padded to at least length n+m−1 so the circular convolution equals the linear one.
The working steps
- If n is 1, the transform is the single sample. Otherwise split the input into even and odd indices.
- Recursively transform both halves.
- For k from 0 to n/2 − 1, let t = ω^k · odd[k]. The output at k is even[k] + t. The output at k+n/2 is even[k] − t.
- ω^k can be computed by successive multiplication by ω, once per level, rather than by a fresh sine and cosine at every k.
- For the inverse, use the opposite sign in ω and divide every output by n.
The O(n log n) bound is arithmetic complexity for a dense DFT. It is not a fast cosine transform by itself, and it is not faster than O(n log n) for a general dense transform. A number-theoretic transform replaces the complex root of unity by a root modulo a prime so that integer convolution stays exact. The split is the same.
Approaches that look simpler and fail
| Approach | Why it fails when the odd branch is combined without the twiddle |
|---|---|
| Add the even and odd transforms with no ω^k | That combines the wrong frequencies. The twiddle rotates the odd branch before it is added and subtracted. |
| Pad a convolution to length n and expect a linear convolution of two length-n signals | Circular wrap mixes the tail into the head. The pad has to reach at least 2n−1. |
| Skip the 1/n on the inverse and compare to the input | The inverse definition includes the division. The unnormalized inverse is n times the signal. |
| Quote O(n log n) for a prime length filled with a radix-2 loop | Radix-2 needs an even split all the way down. A prime length uses a different DFT algorithm or a pad. |
Exact integer convolution uses a number-theoretic transform or a careful modular CRT of integer FFTs. Polynomial multiplication of moderate degree can also use Karatsuba. Cooley-Tukey is the radix-split DFT.
A working example
This Python fragment splits a discrete Fourier transform into even and odd halves and applies the twiddle ω^k. The inverse uses the opposite sign and divides by n. A round trip of 1, 0, -1, 0 returns those samples. It prints 1 0 -1 0.
import cmath
def fft(a, invert=False):
n = len(a)
if n == 1:
return a[:]
even = fft(a[0::2], invert)
odd = fft(a[1::2], invert)
out = [0] * n
sign = 1 if invert else -1
for k in range(n // 2):
t = cmath.exp(sign * 2j * cmath.pi * k / n) * odd[k]
out[k] = even[k] + t
out[k + n // 2] = even[k] - t
return out
data = [1, 0, -1, 0]
back = fft(fft(data), invert=True)
restored = [int(round(z.real / len(data))) for z in back]
assert restored == data
print(*restored)
Where it is used
The Cooley-Tukey FFT is the transform in FFTW, in audio convolution, and in the OFDM radios of Wi-Fi and LTE. MRI and polynomial multiplication use the same split. A DFT that touches every entry is the definition, not the algorithm that runs.
When you can drop this algorithm
Drop a handwritten FFT when a library transform is available and the length is ordinary. Keep the split when the twiddle convention, the inverse scaling, or the convolution pad is the thing that must be understood.
Why this stays published
We publish this so a search for the Cooley-Tukey FFT returns the even-odd split, the twiddle recombination, and the 1/n on the inverse. The Cooley-Tukey algorithm computes a power-of-two DFT in O(n log n) operations by merging two half-length transforms with twiddle factors.
本文由 HoHo 與 AI 協作整理,最後更新於 2026 年 11 月 13 日。
