What Is the Fast Fourier Transform and How Does It Work?

The fast Fourier transform, or FFT, is a recipe for taking a recording of something that changes over time and finding the steady waves hidden inside it. It answers the question “which pitches, or rhythms, or ripples are in this signal, and how strong is each?” The FFT doesn’t compute anything new. It reaches exactly the same answer as the older direct calculation, just by refusing to do the same arithmetic twice.

What the Fourier Transform Does to a Signal

Digital devices store a signal as a list of samples, numbers measured at evenly spaced moments. A microphone recording CD audio reads air pressure 44,100 times a second. The discrete Fourier transform (DFT) turns that finite list into another list of the same length.1Wikipedia. Discrete Fourier transform Each output value describes one frequency: how strong it is (its amplitude) and where its peaks fall in time (its phase).1Wikipedia. Discrete Fourier transform The data switches from a description in terms of moments to a description in terms of oscillations.1Wikipedia. Discrete Fourier transform2Medium. Cup 13: Discrete Fourier Transform — From Time to Frequency Domain The components are sine and cosine waves, each with its own frequency, amplitude and phase.2Medium. Cup 13: Discrete Fourier Transform — From Time to Frequency Domain

A piano chord shows the idea. It reaches the microphone as one wiggly line, not three separate notes. The transform reports three tall spikes, one at each note’s frequency. Taller spikes mean louder notes, and the quiet overtones show up as small spikes. Reverse the transform and the wiggly line is rebuilt from those spikes.1Wikipedia. Discrete Fourier transform

Strength alone tells you how much of each wave is present. Phase says where each wave starts, and that decides how the waves add up, so two signals with identical strengths but different phases can look completely different. Keeping the phase is why the inverse transform recovers the original samples exactly.1Wikipedia. Discrete Fourier transform Nothing is lost; the two lists are two views of the same information.

Reading the output list takes one piece of bookkeeping. The entries are evenly spaced frequencies starting at zero, and the spacing equals the sampling rate divided by the number of samples. The first entry, at zero frequency, is simply the average level of the signal, so a constant offset in the recording shows up there. For a real-valued signal such as sound, the upper half of the output mirrors the lower half, so only about the first half carries independent information. The highest frequency you can see is half the sampling rate, which means CD audio can represent pitches up to about 22,050 hertz.

Why the Direct Calculation Is Slow and How Much the FFT Saves

Computing each output of the DFT directly means multiplying every sample by a wave and adding them all up. Each output therefore costs about n multiplications and additions for n samples. There are n outputs, so the total is n groups of n, about n×n operations.3Wikipedia. Fast Fourier transform Picture a square table of n rows and n columns where every cell is one multiplication.

The FFT cuts the work to about n times logâ‚‚ n operations, where logâ‚‚ n is the number of times n can be halved.3Wikipedia. Fast Fourier transform Its savings come from noticing that many cells of that table hold the same value or are closely related, so the table never needs to be fully filled. For 1,024 samples, the work drops from about a million steps to about 10,000, roughly 100 times less. For a million samples it drops from about a trillion steps to about 20 million, roughly 50,000 times less. A job that would take hours directly can finish in a fraction of a second.

The savings grow with length because doubling the samples quadruples the direct method’s work, while the FFT’s work only slightly more than doubles. The advantage is modest for tiny lists and huge for real recordings.

How the FFT Works, Split, Solve, Combine

The best-known version is the Cooley–Tukey algorithm. In its simplest form it splits the samples into the even-numbered ones and the odd-numbered ones, so one big transform becomes two half-size transforms whose answers can be combined. Each half is split again, and again, until only pairs of numbers remain. This works because the waves used in the calculation repeat their values, so many products in the direct method are identical and need computing only once. Halving the problem about log₂ n times is where the n×log n cost comes from. Each half-size result is used for two different outputs, once with a plus and once with a minus, and that reuse is what saves the work.

The smaller results are merged in small steps that take two numbers and produce their sum and difference after one is adjusted.4Wikipedia. Twiddle factor The adjustment multiplies by a fixed rotation constant.4Wikipedia. Twiddle factor It lines up the odd half’s waves with the even half’s before adding. The angles are evenly spaced around a circle, so they are computed once and reused. More generally, Cooley–Tukey treats one long transform as a grid of smaller transforms done along rows and then columns, with rotation constants in between.5Wikipedia. Cooley–Tukey FFT algorithm

Take 8 samples. Split them into 4 even and 4 odd, then split each group of 4 into two pairs, giving four pairs. Each pair gets one combining step, a sum and a difference. Then the pairs combine into 4s, and the 4s into the full 8, using rotation constants. That is three rounds of combining, matching logâ‚‚ 8 = 3.

Because the repeated splitting scrambles the order of samples, many implementations first reorder them in a pattern called bit-reversed order.6arXiv. Practically efficient methods for performing bit-reversed permutation in C++11 on the x86-64 architecture Write each position number in binary and reverse its digits to get its new place. In an 8-sample list, position 1 (001) swaps with position 4 (100). After reordering, the combining steps can work in place, saving memory. Efficient reordering is a key part of making an FFT fast in practice.6arXiv. Practically efficient methods for performing bit-reversed permutation in C++11 on the x86-64 architecture

What If the Number of Samples Isn’t a Power of Two

The halving trick is simplest when the length is 2, 4, 8, 16 and so on. But lengths built from other small numbers can be split by 3s, 5s or 7s.7High Performance Discrete Fourier Transforms on Graphics Processors. High Performance Discrete Fourier Transforms on Graphics Processors The method splits a length into its factors, so a length like 1,000, which is 2×2×2×5×5×5, breaks into small, cheap pieces. A prime length such as 1,009 has no factors to split by, so the plain trick has nothing to work with. For awkward lengths, including large primes, other methods rewrite the job as a power-of-two FFT.7High Performance Discrete Fourier Transforms on Graphics Processors. High Performance Discrete Fourier Transforms on Graphics Processors Fast graphics-chip FFT libraries combine both approaches to cover any size.7High Performance Discrete Fourier Transforms on Graphics Processors. High Performance Discrete Fourier Transforms on Graphics Processors

Lengths with only small factors are fast, and lengths containing a large prime factor are the slow cases. This is why a length slightly longer or shorter than a round number can sometimes run noticeably faster.

A common everyday workaround is padding the data with zeros to the next power of two. It is easy, but it changes the frequency steps and adds a small, abrupt edge to the data. Exact-length methods keep the spacing you asked for. Most software libraries pick the method for you automatically.

Where the FFT Shows Up in Everyday Technology

4G and 5G mobile networks, Wi-Fi, and digital TV broadcasting use a method that sends data on many closely spaced frequencies at once.8Information systems and technologies security. Fast fourier transform in ofdm: algorithmic approaches and their role in information technologies An FFT is what packs data onto those frequencies at the sender and separates them at the receiver.8Information systems and technologies security. Fast fourier transform in ofdm: algorithmic approaches and their role in information technologies The closely spaced frequencies must be kept from interfering with each other, and the mathematics of the Fourier transform provides exactly that arrangement. The sender builds its signal with an inverse FFT, and the receiver recovers the data with a forward FFT. Doing that with a slow direct method for thousands of frequencies, many times per second, would be impractical on a phone.

MP3 encoders run a 1,024-point FFT on the sound to find which frequencies matter to human hearing.9University of Utah. The Use of FFT and MDCT in MP3 Audio Compression A related transform then packs the sound efficiently while dropping what the ear won’t notice.10Journal of Mathematics. Audio Compression Using Modified Discrete Cosine Transform: The MP3 Coding Standard This pairing can shrink audio files by about 90% with little audible loss.11Medium. The Applications of Fourier Analysis in Audio Compression You may already use FFT output without knowing it: equalizer bars and spectrum displays in music apps are live FFT results, and tuner apps find a note by locating the tallest frequency spike. Noise-reduction features often analyze a quiet stretch’s frequencies and subtract them.

An MRI scanner doesn’t record a picture directly; the data it collects is the Fourier transform of the body’s tissue.12NVIDIA Developer. Chapter 48. Medical Image Reconstruction with the FFT The image is made by running an inverse Fourier transform on the signal.12NVIDIA Developer. Chapter 48. Medical Image Reconstruction with the FFT Faster scans that sample in spirals or spokes use FFT variants built for unevenly spaced data.13PubMed. Direct reconstruction of non-Cartesian k-space data using a nonuniform fast Fourier transform

In ordinary photos and satellite images, a two-dimensional FFT helps remove noise that forms regular patterns.14Geophysics. Processing remote sensing images using the 2-D FFT; noise reduction and other applications Repeating stripes or grids show up as bright isolated dots in the 2-D transform. Erasing those dots and transforming back removes the stripes, while the rest of the picture is barely touched because it lives at other frequencies. Radio telescopes use the FFT to turn signals from arrays of dishes into sky images, under certain simplifying assumptions.15Stellenbosch University. Image reconstruction in radio astronomy with non-coplanar synthesis arrays

What the FFT Can’t Tell You About Timing and Leakage

An FFT describes the frequency content of the whole stretch it analyzes, showing which frequencies exist and how strong, but not when.16MathWorks. FFT vs. STFT It gives a faithful picture only for signals whose content stays steady over that stretch.17Advances in Bioengineering and Biomedical Science Research. Time Frequency Analyses of stationary and non-stationary signals using MATLAB functions and Toolboxes For changing signals like speech, the short-time Fourier transform runs many FFTs on short overlapping slices.17Advances in Bioengineering and Biomedical Science Research. Time Frequency Analyses of stationary and non-stationary signals using MATLAB functions and Toolboxes18Applied Sciences. Area-Efficient Short-Time Fourier Transform Processor for Time–Frequency Analysis of Non-Stationary Signals Shorter slices give sharper timing and blurrier frequencies, a trade-off that can’t be fully escaped.16MathWorks. FFT vs. STFT

Telling two nearby frequencies apart requires watching long enough for them to drift out of step with each other. A short slice does not contain enough cycles to show that drift, so the two merge into one blur. For speech or birdsong, long slices separate close pitches but blur fast changes, while short slices catch quick chirps but merge nearby pitches. Spectrogram apps let you adjust this, usually as an “FFT size” setting.

An FFT treats the stretch it analyzes as if it repeats forever. If the stretch doesn’t hold a whole number of wave cycles, the jump at the ends spreads energy into false frequencies, called spectral leakage.19National Instruments. Understanding FFTs and Windowing The fix is a window function, multiplying the samples by a curve that fades smoothly to zero at both edges.19National Instruments. Understanding FFTs and Windowing20brianmcfee.net. Spectral leakage and windowing Far-off false frequencies then drop sharply, though the true peak spreads slightly wider.20brianmcfee.net. Spectral leakage and windowing Different window shapes trade off leakage in different ways.21Zurich Instruments. How to Control Spectral Leakage with Window Functions in LabOne

A pure tone that shows as a broad hump instead of one spike is a sign of leakage. Turning on a window option such as “Hann” in software usually cuts the spread-out energy far from the peak. Analyzing a stretch holding a whole number of cycles avoids it entirely.

How Accurate the FFT Is

Computers store numbers with limited digits, so every calculation rounds slightly.222023 IEEE 30th Symposium on Computer Arithmetic (ARITH). Testing the Sharpness of Known Error Bounds on the Fast Fourier Transform FFT rounding errors are typically quite small, and Cooley–Tukey has excellent numerical behavior.3Wikipedia. Fast Fourier transform Its structure adds numbers in balanced pairs, which keeps rounding from piling up.3Wikipedia. Fast Fourier transform Rounding error grows with the number of additions a value passes through in sequence, and the pairwise structure keeps that to about log₂ n levels. A direct sum of n terms, added one at a time, passes through many more additions, so the FFT is often slightly more accurate as well as faster. Real errors are usually far smaller than the worst-case limits mathematicians can prove.222023 IEEE 30th Symposium on Computer Arithmetic (ARITH). Testing the Sharpness of Known Error Bounds on the Fast Fourier Transform

Very long transforms or exact integer work may need higher-precision numbers. Tiny nonzero values where you expect zero are usually rounding, not real signals.

Beyond Signals, Big Numbers, Physics and Quantum Computers

Multiplying very large whole numbers can be done with FFT techniques, much faster than schoolbook multiplication.23Mathematics of Computation. Discrete weighted transforms and large-integer arithmetic Record-setting multiplication methods are built on FFT ideas.24arXiv. Fast Integer Multiplication using Modular Arithmetic The link is that the digits of a number can be treated like samples of a signal, and multiplying long numbers resembles blending two signals together. In the frequency view, that blending becomes simple digit-by-digit multiplication. So you transform, multiply, transform back, then carry the digits.

Simulations of heat flow, waves and similar physics often use FFTs to solve their equations.25Revista Mexicana de Física E. Numerical Solution Partial Differential Equations using the Discrete Fourier Transform In frequency terms, rates of change become simple multiplications.26open.umich.edu. Parallel Spectral Numerical Methods A wave’s rate of change is just the same wave shifted in phase and scaled by its frequency, so taking a derivative means multiplying each frequency’s value by a number that depends on that frequency. Equations involving rates of change, which are hard to handle directly, become simple arithmetic for each frequency separately. The solver transforms the data, does the multiplications, and transforms back to get the solution in ordinary space.