Represent a sampled contour with complex Fourier coefficients and measure the error caused by discarding frequencies.
Computing new parameters. The previous result is shown until ready.
Measurements
Samples N
256
Retained terms K
16
DC retained
Yes; counted in K
Sample MSE
1.728e-5
Discarded coefficient energy
1.728e-5
MSE identity residual
9.487e-20
Parseval energy residual
0
Dense reference MSE (selected K)
1.729e-5
Dense reference MSE (all N)
6.978e-10Comparison at 2,048 arclength positions against the saved dense contour reference; this is separate from sample truncation error.
Guided exploration
How does the choice of retained frequencies affect reconstruction error?
Amplitude spectrum
Vertical: |cₖ|
All coefficients
Coefficient phase
Vertical: Phase (rad)
Defined phases
Reconstruction error by term budget
Vertical: Sample MSE (logarithmic scale)
Band-limitedLargest coefficients
Experiment
Save the current parameters and full-precision results, or reproduce the documented study. Importing an experiment reruns its calculation. Display quality and camera position do not affect the exported mathematics.
Direct Float64 complex DFT; forward 1/N, inverse unscaled; closed piecewise-linear equal-arclength resampling; signed Nyquist −N/2; independent sample MSE and omitted coefficient energy.
Model version: fourier-1.0.0. Software: 0.1.0+uncommitted.dirty.f24df3120282. Numerical tolerance: 4.190951585769653e-11.
Unrounded residual: 9.486769009248164e-20
Classification: numerical experiment. Mathematical claims require the stated assumptions and derivations.
Reasoning
Read the definitions, follow the arguments and examine the conditions of each result.
Background: Complex numbers, Sine and cosine, Finite sums. Start with the model for a brief introduction, follow the guided exploration for a closer look, or work through the arguments and experiment for a detailed study.
What you can learn
Use one consistent DFT normalization.
Connect orthogonality to reconstruction and error.
Separate sample reconstruction from the original continuous contour.
Reading step 1 of 5: Specify the sampled contour
Step 1 · Derivation · Selected
Specify the sampled contour
Represent each planar point by one complex number z = x + iy. The input is resampled at equal distances along its closed polygonal path, producing N samples without repeating the endpoint. Automatic closure is part of the input specification and must remain visible. A path with zero total length cannot define this sampling operation.
The transform sees a finite sequence, not an infinitely detailed drawing. Increasing N changes that sequence and may capture additional features of the input. Keeping N fixed while changing the retained term count studies a different question: how well a smaller set of modes represents the same data.
Compare two modes with indices k and ℓ. Their inner product is the average of exp(2πi(k − ℓ)j/N) over all sample indices. If the frequencies agree modulo N, every summand is one. Otherwise the ratio q between consecutive summands satisfies qᴺ = 1 and q ≠ 1.
The finite geometric-series identity then gives (1 − qᴺ)/(1 − q) = 0. This cancellation establishes orthogonality algebraically. The rotating vectors illustrate the terms in that sum, but their appearance on the screen is not the reason the identity holds.
j=0∑N−1qj=1−q1−qN
Theorem. Distinct discrete Fourier modes are orthogonal under the sample-average inner product.
This project puts the factor 1/N in the forward transform. Substitute each coefficient into the inverse sum and exchange the two finite sums. Discrete orthogonality removes every input sample except the one with the required index, whose multiplier is one. The result is exact in arithmetic without rounding.
For display, indices use signed frequencies, including −N/2 at the even-size Nyquist position. This choice agrees at sample locations and specifies the interpolation between them. A complex contour need not have conjugate-symmetric coefficients; that symmetry is specific to real-valued input sequences.
Removing a set of modes leaves an error vector equal to the sum of those omitted modes. Expand its squared norm. Orthogonality makes the mixed terms vanish, leaving the sum of the squared coefficient magnitudes. The workspace evaluates this coefficient energy separately from the average squared differences at the input samples.
For a fixed number of freely selectable coefficients, retaining the largest magnitudes minimizes this discrete squared error. If DC is fixed, optimize only over the remaining available terms and count DC in the budget. This conclusion does not assert optimality for corner appearance, maximum error or another visual criterion.
N1j=0∑N−1∣zj−zj∣2=k∈/S∑∣ck∣2
Theorem. The sample mean squared reconstruction error equals the energy in the omitted coefficients.
MSE=N1j=0∑N−1∣zj−zj∣2=k∈/S∑∣ck∣2
Conditions and assumptions
The reconstruction retains the specified set S.
The same samples and normalization are used on both sides.
With all N terms, numerical reconstruction should recover the N samples within an input-scaled tolerance. Between those locations the displayed curve is a trigonometric interpolant. It need not coincide with the original continuous contour, even when the sample error is nearly zero.
The study compares contours, term budgets and selection rules at a fixed N before changing N. It stores input points, resampling settings and selected frequencies alongside coefficients and errors. A coefficient whose magnitude is near numerical zero has no reliably determined phase; the display identifies that case instead of presenting an arbitrary angle as meaningful.
Project attribution: BIPH Math Society. The exposition was prepared with tool assistance.
Review status: Not reviewed. Independent review by a teacher or society member has not yet been recorded. Numerical checks do not replace mathematical review.
Definitions, signed-frequency conventions and normalization options. This project uses a forward factor of 1/N and an unscaled inverse, corresponding to norm="forward" rather than the library default. The browser implementation does not depend on NumPy. Source checked 16 September 2026.
An author-created explanation connecting complex rotation and frequency. Used as a reference for mathematical exposition, not as a source of copied animation or as a substitute for the finite DFT derivation. Source checked 16 September 2026.