This is a comprehensive request to derive the Cooley-Tukey FFT algorithm. I need to show:
- How the DFT is split into even and odd indices
- The recursive structure
- The complexity reduction from O(N²) to O(N log N)
Let me work through this systematically.
Starting with the DFT Definition
The Discrete Fourier Transform is defined as:
X[k]=∑n=0N−1x[n]e−j2πkn/N
where
- x[n] is the input sequence (n = 0, 1, ..., N-1)
- X[k] is the output (k = 0, 1, ..., N-1)
- N is the number of points (assumes N is even for Cooley-Tukey)
Key Insight: Split by Even and Odd Indices
Let me separate the sum into even and odd indices:
X[k]=∑n=0N−1x[n]e
Split into even indices (n = 2m) and odd indices (n = 2m+1):
X[k]=∑
Simplify the exponents:
X[k]=∑
X[k]=E[k]+WNkO[k]
where WN=e−j2π/N is the twiddle factor, E[k represents the N/2-point DFT of even-indexed samples, and represents the N/2-point DFT of odd-indexed samples. This decomposition reveals the recursive structure: each N-point transform reduces to two N/2-point transforms multiplied by a twiddle factor.
For the second half of the spectrum where k=N/2+j with j=0,1,...,N/2−, I need to account for the periodicity of the N/2-point DFTs. Since and repeat with period N/2, the formula becomes , which simplifies using to give .
This gives me the complete Cooley-Tukey decomposition: the first N/2 outputs use X[k]=E[k]+WNkO[k], while the second half uses .
Now looking at the computational cost, a direct DFT requires N² operations since each of the N output points needs N multiplications and additions. The FFT approach recursively divides the problem: if T(N) represents the operations needed for an N-point transform, I can express this recursively and show how the divide-and-conquer strategy reduces complexity to O(N log N). Continuing the recurrence relation, when i=log2N, we reach the base case where N/2, giving us . This establishes the that makes FFT so efficient compared to direct computation.
The butterfly operation is the core mechanism—it merges even and odd subsequence results by combining an element from the even FFT with a scaled element from the odd FFT, using twiddle factors to weight the contribution.
Cooley-Tukey FFT Algorithm Derivation
1. Starting Point: DFT Definition
The N-point Discrete Fourier Transform is:
X[k]=∑n=0N−1
Naive complexity: O(N²) operations
2. Key Insight: Divide by Even/Odd Indices
Split the sum by separating even indices (n = 2m) and odd indices (n = 2m+1):
X[k]=∑
Simplify the exponents:
X[k]=∑
3. Define Component DFTs
Let:
- Twiddle factor: WN=e−j2π/N
- Even DFT:
Then:
X[k]=E[k]+WNk⋅O[k
4. Complete Recursion Formula
For all output points (using periodicity of N/2-point DFTs):
X[k] &= E[k] + W_N^k \cdot O[k] \quad \text{for } k = 0, 1, \ldots, \frac{N}{2}-1 \\
X[k + N/2] &= E[k] - W_N^k \cdot O[k] \quad \text{for } k = 0, 1, \ldots, \frac{N}{2}-1
\end{align}}$$
**Proof of second equation:**
$$X[k + N/2] = E[k] + W_N^{k+N/2} O[k] = E[k] + W_N^k \cdot W_N^{N/2} O[k]$$
Since $W_N^{N/2} = e^{-j2\pi(N/2)/N} = e^{-j\pi} = -1$:
$$X[k + N/2] = E[k] - W_N^k O[k]$$ ✓
---
## 5. Butterfly Structure
Graphically, each combination is a **butterfly operation**:
```
┌─────────┐
E[k] ─┤ + ├─→ X[k]
└─────────┘
↑
W_N^k ○ O[k]
┌─────────┐
E[k] ─┤ - ├─→ X[k+N/2]
└─────────┘
↑
W_N^k ○ O[k]
```
Each butterfly requires:
- **1 complex multiplication** (twiddle factor)
- **2 complex additions**
---
## 6. Pseudocode Implementation
```python
def cooley_tukey_fft(x):
"""
Recursive Cooley-Tukey FFT
N must be power of 2
"""
N = len(x)
# Base case
if N == 1:
return x
# Divide: separate even and odd indices
even = cooley_tukey_fft([x[n] for n in range(0, N, 2)])
odd = cooley_tukey_fft([x[n] for n in range(1, N, 2)])
# Conquer: combine with butterfly operations
T = [np.exp(-2j * np.pi * k / N) for k in range(N // 2)]
X = [0] * N
for k in range(N // 2):
X[k] = even[k] + T[k] * odd[k]
X[k + N//2] = even[k] - T[k] * odd[k]
return X
```
---
## 7. Complexity Analysis
### Recurrence Relation
Let T(N) = operations needed for N-point FFT:
$$T(N) = 2 \cdot T(N/2) + N$$
where:
- $2 \cdot T(N/2)$ = two N/2-point FFTs
- $N$ = butterfly operations (N/2 butterflies × 2 ops each)
### Solving the Recurrence
By repeated substitution:
$$\begin{align}
T(N) &= 2T(N/2) + N \\
&= 2[2T(N/4) + N/2] + N = 4T(N/4) + 2N \\
&= 4[2T(N/8) + N/4] + 2N = 8T(N/8) + 3N \\
&= 2^i T(N/2^i) + iN
\end{align}$$
When $i = \log_2 N$ (base case reached):
$$T(N) = N \cdot T(1) + N\log_2 N = \boxed{O(N \log_2 N)}$$
### Complexity Comparison
| Operation | Direct DFT | FFT |
|-----------|-----------|-----|
| **Complex Mults** | N² | N log₂ N / 2 |
| **Complex Adds** | N(N-1) | 3N log₂ N / 2 |
| **Speedup** | — | **N / log₂ N** |
**Example:** N = 1024
- Direct DFT: ~1,000,000 operations
- FFT: ~5,000 operations
- **Speedup: ~200×**
---
## 8. Complete Algorithm Flow (N=8)
```
Input: x = [x₀, x₁, x₂, x₃, x₄, x₅, x₆, x₇]
Level 0 (Recursion depth = 3):
├─ Even: [x₀, x₂, x₄, x₆] → FFT(4)
└─ Odd: [x₁, x₃, x₅, x₇] → FFT(4)
Level 1 (Recursion depth = 2):
├─ Even₀: [x₀, x₄] → FFT(2)
├─ Odd₀: [x₂, x₆] → FFT(2)
├─ Even₁: [x₁, x₅] → FFT(2)
└─ Odd₁: [x₃, x₇] → FFT(2)
Level 2 (Recursion depth = 1):
├─ FFT(2): [x₀, x₄] → direct
├─ FFT(2): [x₂, x₆] → direct
└─ ...
Level 3: Combination via butterflies
```
---
## 9. Key Advantages
✓ **Complexity reduction:** O(N²) → **O(N log N)**
✓ **Recursive structure:** Easy to implement
✓ **Cache efficiency:** Natural memory access patterns
✓ **In-place computation:** Bit-reversal permutation for memory efficiency
✓ **Hardware parallelism:** Butterflies can be computed in parallel
---
## 10. Why It Works
The algorithm exploits **divide-and-conquer** at the mathematical level:
- DFT at even/odd indices = smaller DFTs on N/2 samples
- Recursive decomposition reduces problem exponentially
- Each level multiplies cost by 2, but halves problem size
- $\log_2$ levels × $N$ operations per level = **N log N total**
This elegant insight (discovered by Cooley & Tukey in 1965) transformed signal processing from theory to practice.