Fourier Transform & the DFT
Fourier analysis rewrites a signal as amplitudes and phases of complex sinusoids. This entry connects the continuous transform to the finite DFT, derives its frequency grid and inverse, and makes scaling, symmetry, convolution, Parseval's identity, and multidimensional transforms operational rather than mnemonic.
The Fourier transform is a change of coordinates. Instead of asking for a signal's value at each time, it asks how strongly the signal aligns with every rotating complex exponential. Magnitude records how much of a frequency is present; phase records where that component sits in time. No information is lost when the transform and its inverse use a consistent convention.
The continuous transform, Fourier series, discrete-time transform, and DFT answer related but different questions. Most implementation errors come from moving between them without carrying the record duration, sampling interval, frequency grid, and normalization.
One mechanism, four domains #
| Object | Time domain | Frequency domain | Frequency variable |
|---|---|---|---|
| Fourier series | periodic continuous-time function | discrete harmonics | |
| Continuous Fourier transform | aperiodic continuous-time function | continuous spectrum | or |
| DTFT | discrete-time, generally infinite sequence | continuous, periodic spectrum | cycles/sample or rad/sample |
| DFT | exactly samples | exactly frequency samples | bin |
For the continuous convention in hertz,
Using angular frequency moves the into the inverse measure. Neither convention is more correct; mixing them is wrong.
For a finite sequence , NumPy's default DFT convention is
with inverse
The forward transform is unscaled and the inverse carries . Libraries also offer a unitary convention, with in both directions, or a forward-normalized convention. The pair is what matters.
flowchart LR CT["Continuous signal x(t)"] -->|"sample every Δt"| S["N samples x[n]"] S -->|"N-point DFT"| B["N complex bins X[k]"] B -->|"inverse DFT"| S S -->|"interpret with fs and N"| F["frequencies fk = k fs / N"]
A DFT bin is a complex correlation #
The basis vector with index is
The DFT coefficient is the inner product of with : multiply by the conjugate rotating phasor and sum. If the signal rotates at exactly the same rate, every product points in the same direction and adds coherently. Orthogonal bin-centred components sum to zero.
This geometric view explains both amplitude and phase. If
and is neither DC nor Nyquist, then a two-sided unscaled DFT has
The real cosine is the sum of positive- and negative-frequency complex exponentials. Consequently, its amplitude is recovered as from a one-sided plot. DC and the even- Nyquist bin are not doubled because they do not have distinct partners.
The grid follows from the record #
With sampling rate and samples, the observation duration is and the DFT grid spacing is
Bins represent non-negative frequencies. In the usual unshifted ordering, the remaining bins represent negative frequencies:
For even , bin is the Nyquist frequency and represents both and ; for real data it must be real. fftshift only reorders bins so negative frequencies appear left of zero. It does not change the transform.
Longer observation creates a finer physical grid. Appending zeros asks for more samples of the same finite-record transform between the original bins; it makes a curve look smoother but does not separate components that the original duration cannot resolve. Resolution belongs to spectral estimation, not to the array length passed to an FFT routine.
Worked transform: four samples #
Take . It is a unit impulse delayed by one sample:
Every bin has unit magnitude. Delay has changed phase, not magnitude: the phase decreases linearly with frequency. Applying the inverse,
and the other time samples cancel to zero. This is the shift theorem in its smallest nontrivial form.
The same calculation gives a practical invariant: a circular shift by samples multiplies each bin by . If a pipeline moves a waveform and its magnitude spectrum changes substantially, the cause is not the ideal shift alone.
Real signals have conjugate symmetry #
If every is real,
The DC bin is therefore real; for even , the Nyquist bin is real as well. The negative-frequency half is redundant, so real-input routines return values for even . This saves computation and storage, but it does not turn a complex analytic signal into a real signal: calling a real FFT on complex input may discard the imaginary part.
Symmetry also catches data corruption. Except for round-off, a full DFT of a real record must be Hermitian. An unmatched positive-frequency bin means the input or the indexing assumption is not real-valued.
Energy and units #
With the unscaled-forward convention, Parseval's identity is
This is an excellent normalization test. It does not by itself turn into a power spectral density. A PSD has units of signal-unit squared per hertz and must include the sampling rate, window energy, and one- versus two-sided convention. A raw squared magnitude has different units and scales with .
Three common outputs therefore answer different questions:
| Quantity | Typical scaling | Interprets as |
|---|---|---|
| complex coefficient | amplitude and phase in the chosen DFT convention | |
| one-sided sinusoid amplitude | except DC/Nyquist | peak amplitude of a bin-centred real sinusoid |
| PSD estimate | , plus one-sided factors | mean-square contribution per hertz |
The table assumes no detrending and names only the core normalization. An estimator must document its exact convention.
Multiplication and convolution swap roles #
For length- sequences, the DFT diagonalizes circular convolution:
The inverse transform of a product wraps time indices modulo . To compute linear convolution of lengths and with an FFT, zero-pad both to at least before multiplying. Otherwise the tail folds onto the beginning.
Conversely, multiplication by a window in time convolves the signal spectrum with the window spectrum. That is the mechanism behind leakage: recording only a finite interval implicitly multiplies an infinite signal by a rectangular window. Choosing another window changes that convolution kernel; it cannot remove the finite-record tradeoff.
The DFT is a matrix, the FFT is an algorithm #
The DFT can be written with
Each row of is one correlation recipe, so packages all row-by-column dot products at once.
Its rows are orthogonal and . Direct matrix multiplication takes complex operations. Cooley and Tukey's 1965 paper showed how factorizations of split the same transform into smaller transforms; radix-2 FFTs reduce work to . The result is not an approximation and not a different spectrum. FFT refers to a family of algorithms for evaluating the DFT.
Factorization affects speed. Power-of-two lengths are convenient, but modern libraries also handle mixed radices and primes. Padding a length merely to make an FFT fast can alter record interpretation if the caller later mistakes the padded duration for observed data.
Two dimensions and images #
For an array,
The transform is separable: apply a one-dimensional DFT along rows, then columns. Low spatial frequencies describe slowly varying image structure; high frequencies describe rapid changes such as texture and edges. A two-dimensional spectrum is periodic in both axes, and fftshift is commonly used to display DC at the centre.
Image codecs rarely take one global complex DFT. Block transforms such as the DCT use closely related real cosine bases and boundary assumptions that compact energy while avoiding explicit complex coefficients. The coordinate-change idea is the same; the coding constraints differ.
A reliable implementation checklist #
- Record , , units, and the actual timestamp regularity with the samples.
- Decide whether the task needs complex coefficients, amplitudes, power, or PSD.
- State the forward/inverse normalization used by the library.
- Use the library's frequency helper rather than hand-building an even/odd grid.
- For real input, handle DC and Nyquist separately when making a one-sided spectrum.
- Pad to for linear convolution; otherwise expect circular wrap.
- Test inverse reconstruction, Parseval energy, a bin-centred sinusoid, a delayed impulse, and even/odd lengths.
- Treat windowing, detrending, averaging, and confidence as estimator choices outside the bare DFT.
Sources
- docsNumPy: Discrete Fourier Transform
- paperAn Algorithm for the Machine Calculation of Complex Fourier Series
- bookFundamentals of Information Processes 1: Collection, Transmission and Processing of Informationpdfnotes