Project 6: The Fast Fourier Transform (FFT) (The Speed Demon)

Build an FFT implementation and compare its performance to the naive DFT.


Project Overview

Attribute Value
Difficulty Level 2: Intermediate
Time Estimate Weekend
Main Language C
Alternative Languages Python, Rust, C++
Knowledge Area Algorithmic efficiency
Tools Timing tool, plotting tool
Main Book “The Scientist and Engineer’s Guide to DSP” by Steven W. Smith

What you’ll build: An FFT that computes spectra much faster than the DFT for large N.

Why it teaches DSP: The FFT shows how math structure becomes a performance breakthrough.

Core challenges you’ll face:

  • Understanding the divide-and-conquer structure
  • Managing data reordering (bit reversal)
  • Verifying correctness against DFT

Real World Outcome

You will produce an FFT tool that handles large sample sizes and outputs results identical to the DFT but in a fraction of the time.

Example Output:

$ ./fft_analyzer --input output.wav --size 16384
DFT time: 2.8s
FFT time: 0.04s
Max error: 1.2e-6

Verification steps:

  • Compare FFT output to DFT output
  • Measure runtime differences as N grows

The Core Question You’re Answering

“How can the same frequency transform be computed orders of magnitude faster?”

The FFT is a lesson in algorithmic structure, not new math.


Concepts You Must Understand First

Stop and research these before coding:

  1. Even/odd decomposition
    • Why does splitting into even and odd indices help?
    • Book Reference: “The Scientist and Engineer’s Guide to DSP” Ch. 12
  2. Twiddle factors
    • What do the complex rotation factors represent?
    • Book Reference: “Understanding Digital Signal Processing” by Richard G. Lyons, Ch. 12
  3. Bit-reversal ordering
    • Why does the FFT reorder inputs or outputs?
    • Book Reference: “The Scientist and Engineer’s Guide to DSP” Ch. 12

Questions to Guide Your Design

  1. Algorithm choice
    • Will you implement a radix-2 FFT or a more general version?
    • What input sizes will you support?
  2. Validation strategy
    • How will you compare outputs against the DFT?
    • What error threshold is acceptable?

Thinking Exercise

FFT Structure

For N=8, list the even indices and odd indices. Then list the sizes of sub-problems in each stage.

Questions while working:

  • How many stages are required for N=8?
  • How many butterflies exist per stage?

The Interview Questions They’ll Ask

Prepare to answer these:

  1. “Why is the FFT O(N log N) instead of O(N^2)?”
  2. “What are twiddle factors?”
  3. “Why does the FFT require data reordering?”
  4. “What is a butterfly operation?”
  5. “How do you validate an FFT implementation?”

Hints in Layers

Hint 1: Starting Point Start from the DFT formula and separate even and odd terms.

Hint 2: Next Level Use recursion or iterative stages to combine smaller transforms.

Hint 3: Technical Details Precompute twiddle factors to avoid repeated trigonometric calls.

Hint 4: Tools/Debugging Compare FFT output to DFT output for a simple tone and measure error.


Books That Will Help

Topic Book Chapter
FFT basics “The Scientist and Engineer’s Guide to DSP” by Steven W. Smith Ch. 12
Twiddle factors “Understanding Digital Signal Processing” by Richard G. Lyons Ch. 12
Bit reversal “The Scientist and Engineer’s Guide to DSP” by Steven W. Smith Ch. 12

Implementation Hints

  • Keep the transform size fixed to powers of two for the first version.
  • Build a test harness that compares against your DFT implementation.
  • Profile runtime to show the speedup visually.

Learning Milestones

  1. First milestone: You can compute FFT output that matches the DFT.
  2. Second milestone: You can explain why the FFT is faster.
  3. Final milestone: You can reason about FFT stages and butterflies.