A Byte of PhysicsLogo

Fourier transform

The Fourier transform maps a signal from a position or time representation to a frequency representation. A discrete implementation produces a finite array of complex bins—each with magnitude and phase—rather than an infinitely detailed physical spectrum. The transform only has meaning when its sampling and normalization contract travel with the array.

Think like a programmer

Document the forward sign, inverse sign, normalization, sample interval, window, and bin ordering next to the code and output. Use a straightforward O(N²) DFT as a readable oracle before replacing it with an FFT; both must satisfy the same round-trip fixture. Keep complex bins intact until a task specifically needs magnitude or phase, because a magnitude-only spectrum cannot reconstruct the signal.

Model checklist

Inputs
Finite sample array, sample interval Δt, transform convention, normalization, window, and bin ordering.
State
Original samples, complex bins, mapped frequency values, inverse samples, and reconstruction error.
Rule
Sum each input sample against every complex basis value, then inverse-sum bins with the reciprocal convention.
Output
Complex spectrum, magnitude/phase views, physical bin frequencies, and round-trip residual.
Check
Forward then inverse recovers the original finite samples; DC-only input populates bin zero; a bin-aligned sine produces conjugate matching bins; bin frequency is k/(NΔt).
\[X_k=\sum_{n=0}^{N-1}x_n e^{-2\pi i kn/N}\]

The direct DFT maps N samples to N bins. With sample interval Δt, the sample rate is f_s = 1/Δt, and nonnegative bin k initially maps to

\[f_k= rac{k f_s}{N}= rac{k}{NDelta t},qquad x_n= rac{1}{N}sum_{k=0}^{N-1}X_k e^{2pi i kn/N}\]

The inverse normalization shown here is one valid convention. Other libraries may split scaling differently, but forward and inverse must agree. For real samples, the upper bins conventionally represent negative frequencies after wrapping; do not throw them away merely because a graph only shows the lower half.

Discrete spectrum inspector

Choose a bin-aligned sine wave with 16 samples. The bars are DFT magnitudes; a real sine has matching positive- and negative-frequency bins.

DFT magnitude at each bin
Zero magnitude reference

Input sine bin 2; dominant DFT bins 2 and 14, each magnitude 8.0. All other ideal bins are zero up to floating-point error.

The textual result names the input and dominant bins. The bars are only a visualization of the computed DFT magnitudes.

Use small analytic fixtures before analyzing a measurement: all-ones input should place its energy at DC; an impulse has equal-magnitude bins; and a bin-aligned sine has its matching conjugate pair. Then round-trip a nontrivial finite array. These tests reveal wrong signs, swapped indexing, missing normalization, and accidental phase loss long before an FFT makes the implementation too opaque to inspect.

Try this experiment

Prediction: A sinusoid aligned with a bin has a concentrated conjugate pair; moving it off bin spreads energy into nearby bins.

For N = 16 and f_s = 160 Hz, calculate the frequencies of bins 2 and 14. Inspect the matching magnitude bars, then state the inverse normalization used by the code. Design an impulse fixture and predict its magnitude spectrum before evaluating it.

Where this model breaks

Non-bin-aligned frequencies leak into nearby bins. Finite records and window functions change amplitude and resolution interpretation; sample timing jitter, missing samples, nonlinear sensors, clipping, and noise need further models. A DFT assumes uniformly spaced finite samples, so it is not a direct solution for arbitrary continuous signals or irregular observations.

Summary

Use a DFT to expose complex frequency data with declared units and convention. Validate it with DC, impulse, sine, and inverse-reconstruction fixtures before interpreting a magnitude plot from a measured signal.

Glossary

Self-check

  1. What does a DFT output store beyond magnitude?
  2. Why declare normalization and Δt?
  3. Which bin contains a constant input?
  4. What causes leakage?

Sources

Model contract

Treat the lesson as a small function before treating it as a fact to memorize. Give every value a unit, keep only the state needed for the next step, and make the output easy to inspect.

\[\text{observable output} = f(\text{inputs},\,\text{state})\]
Inputs
Quantities you set or measure, with units and useful bounds.
State
Values the program must retain to reproduce the next result.
Rule
The relationship or update that turns inputs and state into a result.
Check
A known limit, unit check, invariant, or measured result that can expose a bad model.

Implement the idea as a model

For Fourier Transform, write down the quantities you can control, the values your program must retain, and the result a reader could inspect. In Waves II — Analysis and Transformations, the useful program is not the drawing: it is the smallest explicit model that makes a prediction you can test.

Guided experiment

Prediction: changing one declared input while holding the others fixed should change only the outputs that the model connects to that input. Choose one input, predict the direction of change, then check a limiting case such as zero, a symmetric arrangement, or a familiar low-speed or small-change approximation.

Where this model breaks

This lesson is a teaching model, not a complete simulator. Before using it outside the stated question, check which interactions, scales, uncertainties, boundary conditions, and measurement limits it leaves out.

Summary

Treat Fourier Transform as a contract: named inputs and units enter a rule, the rule produces an observable result, and a known limit or invariant checks whether the implementation deserves trust.

Glossary

  • Input: a measured value or chosen parameter supplied to a model.
  • State: the smallest set of values needed to continue or reproduce a model.
  • Validation: comparing an output with a known result, limit, invariant, or measurement.

Self-check

  1. Which values are inputs, and which values must remain state?
  2. What observable result would tell you the model is behaving as expected?
  3. Which assumption would you test first before applying the model to a real system?

Model review: turn Fourier Transform into a test

Transform sampled signal arrays into documented complex frequency bins and verify inverse reconstruction.

  1. Name the inputs and units that the waves ii — analysis and transformations model needs.
  2. Separate the state you must keep from values you can calculate when needed.
  3. Write one rule that maps the current state and inputs to an observable result.
  4. Choose a limiting case, unit check, invariant, or known result before trusting an output.
  5. State one assumption you would change before using this simplified model for a real decision.

Share to: