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 k/T0k/T_0
Continuous Fourier transform aperiodic continuous-time function continuous spectrum ff or ω\omega
DTFT discrete-time, generally infinite sequence continuous, periodic spectrum cycles/sample or rad/sample
DFT exactly NN samples exactly NN frequency samples bin kk

For the continuous convention in hertz,

X(f)=∫−∞∞x(t)e−j2πft dt,x(t)=∫−∞∞X(f)ej2πft df.X(f)=\int_{-\infty}^{\infty}x(t)e^{-j2\pi ft}\,dt, \qquad x(t)=\int_{-\infty}^{\infty}X(f)e^{j2\pi ft}\,df.

Using angular frequency ω=2πf\omega=2\pi f moves the 2π2\pi into the inverse measure. Neither convention is more correct; mixing them is wrong.

For a finite sequence x[0],…,x[N−1]x[0],\ldots,x[N-1], NumPy's default DFT convention is

X[k]=∑n=0N−1x[n]e−j2πkn/N,k=0,…,N−1,X[k]=\sum_{n=0}^{N-1}x[n]e^{-j2\pi kn/N}, \qquad k=0,\ldots,N-1,

with inverse

x[n]=1N∑k=0N−1X[k]ej2πkn/N.x[n]=\frac{1}{N}\sum_{k=0}^{N-1}X[k]e^{j2\pi kn/N}.

The forward transform is unscaled and the inverse carries 1/N1/N. Libraries also offer a unitary convention, with 1/N1/\sqrt N in both directions, or a forward-normalized convention. The pair is what matters.

A DFT bin is a complex correlation #

The basis vector with index kk is

vk[n]=ej2πkn/N.v_k[n]=e^{j2\pi kn/N}.

The DFT coefficient X[k]X[k] is the inner product of xx with vkv_k: 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

x[n]=Acos⁡(2πk0n/N+ϕ),x[n]=A\cos\left(2\pi k_0n/N+\phi\right),

and k0k_0 is neither DC nor Nyquist, then a two-sided unscaled DFT has

X[k0]=AN2ejϕ,X[N−k0]=AN2e−jϕ.X[k_0]=\frac{AN}{2}e^{j\phi}, \qquad X[N-k_0]=\frac{AN}{2}e^{-j\phi}.

The real cosine is the sum of positive- and negative-frequency complex exponentials. Consequently, its amplitude is recovered as 2∣X[k0]∣/N2|X[k_0]|/N from a one-sided plot. DC and the even-NN Nyquist bin are not doubled because they do not have distinct partners.

The grid follows from the record #

With sampling rate fsf_s and NN samples, the observation duration is T=N/fsT=N/f_s and the DFT grid spacing is

Δf=fsN=1T.\Delta f=\frac{f_s}{N}=\frac{1}{T}.

Bins 0…⌊N/2⌋0\ldots\lfloor N/2\rfloor represent non-negative frequencies. In the usual unshifted ordering, the remaining bins represent negative frequencies:

fk={kfs/N,0≤k≤⌊N/2⌋,(k−N)fs/N,⌊N/2⌋<k<N.f_k=\begin{cases} kf_s/N,&0\le k\le\lfloor N/2\rfloor,\\ (k-N)f_s/N,&\lfloor N/2\rfloor<k<N. \end{cases}

For even NN, bin N/2N/2 is the Nyquist frequency and represents both +fs/2+f_s/2 and −fs/2-f_s/2; 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 x=[0,1,0,0]x=[0,1,0,0]. It is a unit impulse delayed by one sample:

X[k]=e−j2πk/4=[1,−j,−1,j].X[k]=e^{-j2\pi k/4}=[1,-j,-1,j].

Every bin has unit magnitude. Delay has changed phase, not magnitude: the phase decreases linearly with frequency. Applying the inverse,

x[1]=14(1+(−j)j+(−1)(−1)+j(−j))=1,x[1]=\frac14\left(1+(-j)j+(-1)(-1)+j(-j)\right)=1,

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 n0n_0 samples multiplies each bin by e−j2πkn0/Ne^{-j2\pi kn_0/N}. 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 x[n]x[n] is real,

X[(−k) mod N]=X[k]∗.X[(-k)\bmod N]=X[k]^*.

The DC bin X[0]X[0] is therefore real; for even NN, the Nyquist bin X[N/2]X[N/2] is real as well. The negative-frequency half is redundant, so real-input routines return N/2+1N/2+1 values for even NN. 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

∑n=0N−1∣x[n]∣2=1N∑k=0N−1∣X[k]∣2.\sum_{n=0}^{N-1}|x[n]|^2=\frac{1}{N}\sum_{k=0}^{N-1}|X[k]|^2.

This is an excellent normalization test. It does not by itself turn ∣X[k]∣2|X[k]|^2 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 NN.

Three common outputs therefore answer different questions:

Quantity Typical scaling Interprets as
complex coefficient X[k]X[k] amplitude and phase in the chosen DFT convention
one-sided sinusoid amplitude 2∣X[k]∣/N2\lvert X[k]\rvert/N except DC/Nyquist peak amplitude of a bin-centred real sinusoid
PSD estimate ∣Xw[k]∣2/(fs∑w2)\lvert X_w[k]\rvert^2/(f_s\sum w^2), 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-NN sequences, the DFT diagonalizes circular convolution:

DFT{x⊛h}[k]=X[k]H[k].\mathop{\mathrm{DFT}}\{x\circledast h\}[k]=X[k]H[k].

The inverse transform of a product wraps time indices modulo NN. To compute linear convolution of lengths LxL_x and LhL_h with an FFT, zero-pad both to at least Lx+Lh−1L_x+L_h-1 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 X=FxX=Fx with

Fk,n=e−j2πkn/N.F_{k,n}=e^{-j2\pi kn/N}.

Each row of FF is one correlation recipe, so FxFx packages all NN row-by-column dot products at once.

Its rows are orthogonal and F−1=F∗/NF^{-1}=F^*/N. Direct matrix multiplication takes O(N2)O(N^2) complex operations. Cooley and Tukey's 1965 paper showed how factorizations of NN split the same transform into smaller transforms; radix-2 FFTs reduce work to O(Nlog⁡N)O(N\log N). 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 M×NM\times N array,

X[k,ℓ]=∑m=0M−1∑n=0N−1x[m,n]e−j2π(km/M+ℓn/N).X[k,\ell]=\sum_{m=0}^{M-1}\sum_{n=0}^{N-1} x[m,n]e^{-j2\pi(km/M+\ell n/N)}.

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 #

  1. Record fsf_s, NN, units, and the actual timestamp regularity with the samples.
  2. Decide whether the task needs complex coefficients, amplitudes, power, or PSD.
  3. State the forward/inverse normalization used by the library.
  4. Use the library's frequency helper rather than hand-building an even/odd grid.
  5. For real input, handle DC and Nyquist separately when making a one-sided spectrum.
  6. Pad to Lx+Lh−1L_x+L_h-1 for linear convolution; otherwise expect circular wrap.
  7. Test inverse reconstruction, Parseval energy, a bin-centred sinusoid, a delayed impulse, and even/odd lengths.
  8. Treat windowing, detrending, averaging, and confidence as estimator choices outside the bare DFT.

Sources

  1. docsNumPy: Discrete Fourier Transform
  2. paperAn Algorithm for the Machine Calculation of Complex Fourier Series
  3. bookFundamentals of Information Processes 1: Collection, Transmission and Processing of Informationpdfnotes

Searches titles, aliases, headings, summaries, and full text.↑↓ move ↵ open esc close