{"id":160,"date":"2026-11-13T12:33:08","date_gmt":"2026-11-13T04:33:08","guid":{"rendered":"https:\/\/hoho.live\/luda\/index.php\/2026\/11\/13\/how-cooley-tukey-splits-a-discrete-fourier-transform\/"},"modified":"2026-11-13T21:51:33","modified_gmt":"2026-11-13T13:51:33","slug":"how-cooley-tukey-splits-a-discrete-fourier-transform","status":"publish","type":"post","link":"https:\/\/hoho.live\/luda\/index.php\/2026\/11\/13\/how-cooley-tukey-splits-a-discrete-fourier-transform\/","title":{"rendered":"How Cooley-Tukey splits a discrete Fourier transform"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Short answer:<\/strong> The <strong>Cooley-Tukey FFT<\/strong> 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 \u03c9^k. The recurrence T(n) = 2T(n\/2) + O(n) solves to <strong>O(n log n)<\/strong> arithmetic operations. A direct DFT is <strong>O(n\u00b2)<\/strong>. The same split works for any highly composite length. Radix-2 is the form to implement first.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>What the problem actually asks<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">The DFT sums x[j] \u00b7 \u03c9^{jk} for every frequency k, with \u03c9 = e^{\u22122\u03c0i\/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], \u2026. The odd subtransform is the DFT of x[1], x[3], \u2026. Frequency k and frequency k+n\/2 reuse those two results with a sign change on the odd branch.<\/p>\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>What the algorithm guarantees<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">The algorithm returns the same numbers as the definition of the DFT, up to floating-point rounding. Time is \u0398(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 \u03c9^{+2\u03c0i\/n}, and divides by n. Forgetting the division returns n times the original signal.<\/p>\n\n\n<p class=\"wp-block-paragraph\">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\u22121 so the circular convolution equals the linear one.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>The working steps<\/strong><\/h4>\n\n<ol class=\"wp-block-list\">\n<li>If n is 1, the transform is the single sample. Otherwise split the input into even and odd indices.<\/li>\n<li>Recursively transform both halves.<\/li>\n<li>For k from 0 to n\/2 \u2212 1, let t = \u03c9^k \u00b7 odd[k]. The output at k is even[k] + t. The output at k+n\/2 is even[k] \u2212 t.<\/li>\n<li>\u03c9^k can be computed by successive multiplication by \u03c9, once per level, rather than by a fresh sine and cosine at every k.<\/li>\n<li>For the inverse, use the opposite sign in \u03c9 and divide every output by n.<\/li>\n<\/ol>\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>Approaches that look simpler and fail<\/strong><\/h4>\n\n<figure class=\"wp-block-table\">\n<table>\n<thead>\n<tr>\n<th>Approach<\/th>\n<th>Why it fails when the odd branch is combined without the twiddle<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Add the even and odd transforms with no \u03c9^k<\/td>\n<td>That combines the wrong frequencies. The twiddle rotates the odd branch before it is added and subtracted.<\/td>\n<\/tr>\n<tr>\n<td>Pad a convolution to length n and expect a linear convolution of two length-n signals<\/td>\n<td>Circular wrap mixes the tail into the head. The pad has to reach at least 2n\u22121.<\/td>\n<\/tr>\n<tr>\n<td>Skip the 1\/n on the inverse and compare to the input<\/td>\n<td>The inverse definition includes the division. The unnormalized inverse is n times the signal.<\/td>\n<\/tr>\n<tr>\n<td>Quote O(n log n) for a prime length filled with a radix-2 loop<\/td>\n<td>Radix-2 needs an even split all the way down. A prime length uses a different DFT algorithm or a pad.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>A working example<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">This Python fragment splits a discrete Fourier transform into even and odd halves and applies the twiddle \u03c9^k. The inverse uses the opposite sign and divides by n. A round trip of 1, 0, -1, 0 returns those samples. It prints <code>1 0 -1 0<\/code>.<\/p>\n\n<pre><code class=\"language-python\">import cmath\ndef fft(a, invert=False):\n    n = len(a)\n    if n == 1:\n        return a[:]\n    even = fft(a[0::2], invert)\n    odd = fft(a[1::2], invert)\n    out = [0] * n\n    sign = 1 if invert else -1\n    for k in range(n \/\/ 2):\n        t = cmath.exp(sign * 2j * cmath.pi * k \/ n) * odd[k]\n        out[k] = even[k] + t\n        out[k + n \/\/ 2] = even[k] - t\n    return out\n\ndata = [1, 0, -1, 0]\nback = fft(fft(data), invert=True)\nrestored = [int(round(z.real \/ len(data))) for z in back]\nassert restored == data\nprint(*restored)\n<\/code><\/pre>\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>Where it is used<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">The <strong>Cooley-Tukey FFT<\/strong> 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.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>When you can drop this algorithm<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>Why this stays published<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">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. <strong>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.<\/strong><\/p>\n\n\n<p class=\"wp-block-paragraph\">\u672c\u6587\u7531 HoHo \u8207 AI \u5354\u4f5c\u6574\u7406\uff0c\u6700\u5f8c\u66f4\u65b0\u65bc 2026 \u5e74 11 \u6708 13 \u65e5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 \u03c9^k. The recurrence T(n) = 2T(n\/2) + O(n) solves to O(n&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30,47],"tags":[],"class_list":["post-160","post","type-post","status-publish","format-standard","hentry","category-algorithms","category-transforms"],"_links":{"self":[{"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/posts\/160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/comments?post=160"}],"version-history":[{"count":2,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/posts\/160\/revisions"}],"predecessor-version":[{"id":559,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/posts\/160\/revisions\/559"}],"wp:attachment":[{"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/media?parent=160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/categories?post=160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/tags?post=160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}