The Fast Fourier Transform (FFT)

EEEN 462 — Analog Communications

Department of Electrical & Electronic Engineering, Egerton University

4th Year Undergraduate Tutorial

1Introduction

In EEEN 462 — Analog Communications you analyse signals in the frequency domain: the spectrum of an AM or FM waveform, the bandwidth a channel needs, the interference a transmitter leaks into adjacent channels. The mathematical tool behind every spectrum analyser, software-defined radio (SDR), and digital receiver is the Discrete Fourier Transform (DFT). The problem is cost: a direct DFT of N points needs on the order of N² complex multiplications, which for the sample counts used in practice (thousands to millions) is prohibitive.

The Fast Fourier Transform (FFT) is not a new transform — it is a family of algorithms that compute exactly the same DFT with dramatically fewer operations. The most famous, the radix-2 Cooley–Tukey algorithm published in 1965 by James Cooley and John Tukey, reduces the cost from ~N² to ~N log₂N multiplications. This single algorithm made real-time digital spectral analysis, OFDM (Wi-Fi, 4G, 5G), digital demodulation, and modern SDR receivers computationally feasible.

Key message: FFT computes the identical DFT output — no approximation. The "fast" comes purely from exploiting symmetries of the complex exponential to avoid redundant calculations.

A brief history

YearMilestone
1805Carl Friedrich Gauss (unpublished) uses an FFT-like method to interpolate asteroid orbits — the algorithm predates the DFT itself by 160 years.
1965Cooley & Tukey publish the radix-2 decimation-in-time FFT in Mathematics of Computation; the computer era adopts it immediately.
1967Bergland extends to radix-4, radix-8 and mixed-radix algorithms.
1997FFTW ("Fastest Fourier Transform in the West") — self-optimising library used in MATLAB, Python and most scientific computing.
TodayEvery spectrum analyser, SDR, LTE/5G modem (OFDM uses the IFFT/FFT pair), audio codec and medical imaging system relies on it.
Figure 1.1 — Why the FFT matters: the same 1,024-sample signal, analysed instantly Direct DFT (N = 1024) ≈ N² = 1,048,576 complex multiplications ≈ 200× slower than FFT Radix-2 FFT (N = 1024) ≈ (N/2)·log₂N = 5,120 complex multiplications identical result, real-time speed

Same mathematics, radically different cost — the FFT removes the redundancy hidden inside the DFT sum.

2Discrete Fourier Transform (DFT) — A Quick Recap

2.1 Definition

Given N samples x[n], n = 0,…,N−1, taken at sampling rate f_s, the DFT is:

DFT (analysis equation) X[k] = Σn=0N−1 x[n] e−j 2π k n / N,    k = 0,…,N−1

and the inverse (IDFT) reconstructs the time sequence:

IDFT (synthesis equation) x[n] = (1/N) Σk=0N−1 X[k] ej 2π k n / N

Interpretation: each X[k] is the correlation of x[n] with a complex sinusoid of frequency f_k = k·f_s/N. |X[k]| tells how much of that frequency component is present; ∠X[k] its phase. For real x[n], the spectrum is conjugate symmetric: X[N−k] = X*[k].

2.2 The twiddle factor

The complex exponential appears so often that we give it a name:

Twiddle factor WN = e−j 2π / N   ⇒   WNkn = e−j 2π k n / N

The twiddle factor has two crucial properties that the entire FFT is built on:

Symmetry property WNk + N/2 = −WNk   (rotating by half a turn flips the sign)
Periodicity property WNk + N = WNk   (the values repeat every N)
Figure 2.1 — Twiddle factors W₈ᵏ on the unit circle W₈⁰=1 W₈¹ W₈²=−j W₈⁴=−1 W₈⁵=−W₈¹ W₈⁷=−W₈³ Green: unique values • Red: negatives of unique values (symmetry)

For N = 8 there are only 4 distinct twiddle values; the other 4 are their negatives — the redundancy the FFT exploits.

2.3 Cost of the direct DFT

Each of the N outputs requires N complex multiplications and N−1 additions ⇒ about N² multiplications. For the modest N = 4096: 16.8 million multiplications — at 1 µs each, ~17 s per transform. A spectrum analyser updating 50 times per second is impossible. Something smarter is needed.

3The FFT — Divide and Conquer

3.1 Splitting the DFT sum

Separate the N-point sequence into its even-indexed and odd-indexed samples:

xe[r] = x[2r],    xo[r] = x[2r+1],    r = 0,…,N/2−1

Substitute n = 2r (even) and n = 2r+1 (odd) into the DFT definition:

X[k] = Σr=0N/2−1 x[2r] WN2rk + Σr=0N/2−1 x[2r+1] WN(2r+1)k

Since WN2rk = WN/2rk and WNk factors out of the odd sum:

Decimation in Time (DIT) decomposition X[k] = Xe[k] + WNk Xo[k],    k = 0,…,N/2−1

where Xe[k] and Xo[k] are the N/2-point DFTs of the even and odd subsequences. Now use the symmetry property WNk+N/2 = −WNk to get the upper half of the spectrum for free:

Upper half — no new computation needed X[k + N/2] = Xe[k] − WNk Xo[k],    k = 0,…,N/2−1
The whole trick: one N-point DFT = two N/2-point DFTs + N/2 "butterfly" combinations. Apply the same split recursively until you reach 2-point DFTs — each of which is a trivial add/subtract.
Figure 3.1 — Divide and conquer: one N-point DFT built from two N/2-point DFTs N-point DFT cost ≈ N² ⇒ N/2-point DFT even samples x[2r] N/2-point DFT odd samples x[2r+1] Combine stage N/2 butterflies with Wₙᵏ X[k], X[k+N/2] full N-point spectrum

Recursion continues on each half until only 2-point DFTs remain.

3.2 How many levels?

Each split halves the problem size: N → N/2 → N/4 → … → 2. Starting from N = 2m, exactly m = log₂N levels of recursion are needed. This logarithm is where the FFT's speed comes from.

Recursion depth (radix-2) N = 2m   ⇒   m = log₂N levels,   each level has N/2 butterflies
Analogy: this is the same "halving" idea as binary search — instead of scanning N items one by one, you halve the problem at each step and finish in log₂N steps.

4The Butterfly Operation

The butterfly is the atomic unit of the FFT: the combine step for each k.

Butterfly equations (radix-2 DIT) U = a + WNk·b
V = a − WNk·b
Figure 4.1 — The radix-2 butterfly: one complex multiply, one add, one subtract a b × Wₙᵏ U = a+Wₙᵏb V = a−Wₙᵏb + −

The crossing lines resemble a butterfly's wings — hence the name. Note the minus sign comes from Wₙ^(k+N/2) = −Wₙᵏ.

4.1 Why is the butterfly so cheap?

Operation per butterflyCount
Complex multiplications1 (the twiddle Wₙᵏ·b)
Complex additions2 (a + product, a − product)
Trivial twiddlesAt k = 0 and k = N/2, Wₙᵏ = ±1 — multiply can be skipped
Cost of the whole transform: (N/2 butterflies per level) × (log₂N levels) × (1 complex multiply) = (N/2)·log₂N complex multiplications — versus N² for the direct DFT.

5FFT Algorithm Steps (Radix-2 Decimation in Time)

Step 1 — Check the length

Radix-2 requires N = 2m (pad with zeros if necessary). Mixed-radix libraries handle other sizes.

Step 2 — Bit-reversal permutation

Recursively taking even/odd samples reorders the input. The required order is the bit-reversed index: write n in binary with log₂N bits, reverse the bits, and place x[n] at that position.

Index n (decimal)Binary (3 bits)Bit-reversedFFT input position
00000000
10011004
20100102
30111106
41000011
51011015
61100113
71111117
Figure 5.1 — Bit-reversal reordering for N = 8 x[0]x[1]x[2]x[3] x[4]x[5]x[6]x[0] x[4]x[2]x[6] x[1]x[5]x[3] reverse the 3 bits of each index

Straight-through for indices 0 and 7; the rest swap in mirrored pairs (1↔4, 2↔2 stays, 3↔6, 5↔5 stays).

Step 3 — Build butterflies, level by level

Starting from adjacent pairs (spacing 1), apply butterflies with progressively wider spans and the twiddles of the corresponding size. Each level l uses W2lk.

LevelButterfly spanTwiddles usedNumber of butterflies
11 (adjacent)W₂⁰ = 1 onlyN/2
22W₄⁰, W₄¹N/2
34W₈⁰…W₈³N/2
………N/2
log₂NN/2WN⁰…WNN/2−1N/2

Step 4 — Full 8-point flow graph

Figure 5.2 — Complete radix-2 DIT FFT flow graph, N = 8 (input bit-reversed, output natural order) x[0]x[4]x[2]x[6] x[1]x[5]x[3]x[7] X[0]X[1]X[2]X[3] X[4]X[5]X[6]X[7] W₄⁰=1W₄¹=−j W₄⁰=1W₄¹=−j W₈⁰=1W₈¹ W₈²=−jW₈³ W₈⁰=1W₈¹ W₈²=−jW₈³ Level 1: span 1, W₂ = 1 Level 2: span 2, W₄ Level 3: span 4, W₈ Output X[k]

log₂8 = 3 levels × 4 butterflies = 12 butterflies ⇒ 12 complex multiplies vs 64 for the direct DFT.

Step 5 — Worked example (N = 4)

Let x[n] = [1, 1, 0, 0]. Bit-reversed order: [x[0], x[2], x[1], x[3]] = [1, 0, 1, 0].

Level 1 (2-point DFTs): (1,0) → (1, 1);   (1,0) → (1, 1)
Level 2 (combine with W₄⁰=1, W₄¹=−j): X[0] = 1 + 1·1 = 2;   X[1] = 1 + (−j)(1) = 1 − j;
X[2] = 1 − 1·1 = 0;   X[3] = 1 − (−j)(1) = 1 + j ✓ (matches the direct DFT)

6Computational Complexity: DFT vs FFT

NDFT multiplies (N²)FFT multiplies ((N/2)·log₂N)Speed-up
864125.3×
644,09619221×
1,0241,048,5765,120205×
4,09616,777,21624,576683×
1,048,576 (2²⁰)1.1 × 10¹²10,485,760≈ 105,000×
Figure 6.1 — Growth comparison (log scale): N² explodes, N·log₂N grows gently DFT: N² FFT: (N/2)·log₂N small Nlarge N → cost (log scale)

The gap widens without bound: every doubling of N multiplies DFT cost by 4 but FFT cost only by ~2.

Rule of thumb: the FFT advantage exceeds 100× for N ≥ 1024 and grows linearly with N. This is why "DFT" and "FFT" are used interchangeably in practice — nobody computes the raw sum.

7Implementing the FFT

7.1 From scratch in Python (educational version)

import numpy as np

def fft(x):
    """Recursive radix-2 DIT FFT. Length must be a power of 2."""
    x = np.asarray(x, dtype=complex)
    N = len(x)
    if N == 1:
        return x
    if N % 2:                      # radix-2 needs N = 2^m
        raise ValueError("N must be a power of 2")
    even = fft(x[0::2])            # decimate: even samples
    odd  = fft(x[1::2])            # decimate: odd samples
    k = np.arange(N // 2)
    W = np.exp(-2j * np.pi * k / N)          # twiddles W_N^k
    return np.concatenate([even + W * odd,
                           even - W * odd])

# Test: compare against numpy
x = [1, 1, 0, 0]
print(fft(x))          # [2, 1-1j, 0, 1+1j]  ✓
print(np.fft.fft(x))   # identical

7.2 Production code — never reinvent the wheel

# Python / NumPy  (FFTW under the hood in SciPy)
import numpy as np
X = np.fft.fft(x)            # forward FFT
x = np.fft.ifft(X)           # inverse FFT
mag = np.abs(X[:N//2])       # single-sided magnitude spectrum
freqs = np.fft.fftfreq(N, d=1/fs)
% MATLAB / Octave
X = fft(x);                  % forward FFT
x = ifft(X);                 % inverse FFT
f = (0:N-1)*(fs/N);          % frequency axis
plot(f(1:N/2), abs(X(1:N/2)))
// C with FFTW (de-facto standard library)
#include <fftw3.h>
fftw_complex *in, *out;
fftw_plan p = fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
fftw_execute(p);             // out[] now holds the DFT
fftw_destroy_plan(p);

7.3 Try it live — in-browser FFT demo

Left: time-domain samples. Right: single-sided magnitude spectrum |X[k]| computed by a radix-2 FFT implemented in JavaScript in this page — the same algorithm described above.

Practical pitfalls when implementing: (1) input must be bit-reversed (or use a self-sorting variant); (2) N must be a power of 2 for radix-2 — otherwise use mixed-radix (NumPy/FFTW handle any N); (3) remember the FFT is linear in N — scale by 1/N only for the IDFT, depending on convention.

8Applications of the FFT

Directly in EEEN 462 topics

  • Spectrum analysers: the displayed trace is |FFT|² of the digitised input, updated in real time thanks to the FFT.
  • AM/FM lab work: the frequency-spectrum plots in your virtual labs are FFTs of the simulated waveforms — verifying sideband structure and Carson bandwidth.
  • SDR receivers: the mixer + low-pass + FFT chain replaces analogue filters; stations appear as peaks in the spectrum.
  • Distortion measurement: THD and intermodulation products read off an FFT of the amplifier output.

Modern communications & beyond

  • OFDM / OFDMA (Wi-Fi, LTE, 4G/5G): the transmitter uses the IFFT to synthesise subcarriers, the receiver uses the FFT to separate them — millions of FFTs per second per device.
  • Channel sounding & equalisation: FFT/IFFT convert between the time-domain channel impulse response and frequency response.
  • Radar & sonar: pulse compression (matched filtering) and Doppler processing are FFT-based.
  • Audio & image compression: MP3, AAC and JPEG operate on frequency-domain coefficients obtained by FFT-like transforms.
  • Medical & scientific imaging: MRI reconstruction is fundamentally an FFT.
Figure 8.1 — The FFT at the heart of a modern digital receiver Antenna + LNA ADC(sample) Digital mixer× e^(−j2πf_LO t) Window +FFT (N pts) Channelise /demodulate m̂(t) / data

What was once racks of analogue filters is now one FFT — the reason your phone can decode Wi-Fi, 4G and 5G in real time.

Course takeaway: the FFT turns the DFT from a textbook formula into a real-time engineering tool. Whenever you see a spectrum plot — in the lab, in MATLAB, or in a receiver — an FFT like the one in this tutorial computed it.