- Lines 1–7 set the grid dimensions, domain lengths, thermal diffusivity and time interval. The elapsed time is .
- Lines 9–10 supply coordinates, subject to the periodic-grid correction above. Lines 16–17 sample the initial Gaussian function.
- Lines 11–14 construct the discrete Fourier transform frequency order and . Negative frequencies occupy the second half of each array. This is the discrete version of replacing each spatial derivative by multiplication by .
- Line 20 computes the two-dimensional Fast Fourier transform. Lines 22–24 multiply every mode by at every step, implementing the modal solution derived above.
- Line 26 performs the inverse discrete Fourier transform. Taking the real part removes tiny imaginary roundoff errors; conjugate symmetry of the exact transformed real data already guarantees a real result.
- Lines 28–42 display the initial and final arrays. A common colour scale is needed to compare their peak temperatures; independent automatic colour scales can hide the decrease in amplitude.
For this linear homogeneous problem, the exponential update is exact for the retained modes, apart from roundoff error. It is not a forward Euler method step and does not require the explicit finite-difference diffusion stability restriction. Sampling, periodic modelling and spatial resolution still matter.
A spatially uniform source changes only the zero Fourier mode. Its exact integrated increment over a time step beginning at isThe unnormalised two-dimensional discrete Fourier transform stores a constant field as in element This replacement uses the original variable names and MATLAB indexing. The uniform forcing of a periodic heat equation is integrated exactly in time here. No source multiplier is applied to the other modes, and the zero-mode homogeneous multiplier equals one. Adding only
(1,1).[ref]fft2 documentation by MathWorks. The forward defining sum has no normalization; the linked inverse definition includes the factor .
Keep the existing homogeneous exponential multiplication and add this source increment to that element:for i = 1:nt
t = (i-1)*dt;
u_hat = u_hat .* exp(-alpha*K2*dt);
dq = exp(-t/10) - exp(-(t+dt)/10);
u_hat(1,1) = u_hat(1,1) + nx*ny*dq;
enddq to the unnormalised coefficient would underestimate the physical temperature increment by the factor .Peak phasor versus positive-frequency Fourier coefficient distinguishes a real sinusoid's reconstruction amplitude from one coefficient in its two-sided exponential expansion. For ,Thus the positive-frequency Fourier coefficient is half the peak amplitude phasor. The negative-frequency coefficient is its conjugate. A real sinusoid needs both; a complex exponential input has a different one-sided reconstruction.
The distinction also controls a sampled record. For evenly spaced samples of a real sinusoid with exactly cycles in the record and , use the unscaled forward discrete Fourier transformOrthogonality of the discrete exponentials gives . ConsequentlyThe default SciPy forward FFT has exactly this unscaled convention; its forward and orthonormal modes have different factors.[ref]
SciPy 1.16.2 documentation. scipy.fft.fft, Parameters: norm; Notes: forward sum and real-input symmetry
For an original example, sample volts. Then volts and volts. Dividing by 64 gives the positive-frequency coefficient volts; doubling it recovers the peak phasor. The RMS amplitude is volts.
These exact relations assume coherent sampling of the stated sinusoid without aliased extra components. DC and, for even , the Nyquist bin do not have distinct conjugate partners and must not be doubled. With a noninteger number of cycles or a windowed record, finite-record phasor extraction with coherent sampling must be distinguished from a generic bin readout; spectral leakage and the window's amplitude normalization alter the estimate. The parent peak amplitude phasor specifies the continuous-time convention before any sampled transform is chosen.
Consider the discrete linear system withThis is a finite periodic analogue of the Poisson equation, using the negative second finite difference with unit grid spacing. It is also a Graph Laplacian equation on a cycle graph; no continuum approximation is being claimed here.
Summing the four equations gives zero on the left, since each value occurs twice positively and twice negatively. A necessary condition is therefore . The Fourier diagonalization of a circulant matrix shows that this is also sufficient: the only zero eigenvalue of is the constant mode , and .
For the displayed forcing, the discrete Fourier transform givesDivide only at the three nonzero eigenvalues, and choose to impose zero arithmetic mean:Direct substitution gives . All other vectors satisfying the linear system are , because the kernel is the space of constant vectors. Thus balanced forcing determines the differences between values, while a reference level is an extra choice. This small model explains why a periodic Poisson equation needs both a compatibility condition and a normalization.
Periodogram 2026-10-06
For a centered record of length , the periodogram is the squared modulus of its discrete Fourier transform, with normalizationUnder suitable short-memory assumptions its expectation approaches the spectral density of a stationary process, but its variance generally does not vanish. Smoothing nearby frequencies can provide an estimate with statistical consistency.
Prime Fourier matrix minor theorem 2026-10-14
For a prime , distinct row and column residues and , every square discrete Fourier transform submatrix is nonsingular. Sort the selected column exponents decreasingly as and write . Its determinant factors by the bialternant formula into a nonzero Vandermonde determinant and . Modulo , this Schur factor is in . The Schur evaluation at all ones product has numerator and denominator differences strictly between zero and , so its residue is nonzero. The Schur factor, and hence the minor, cannot vanish.
Pseudospectral method 2026-11-05
A pseudospectral method represents an approximate solution through a global basis or its interpolating values and imposes equations at selected collocation points. In a periodic problem the basis is often a Fourier series; on an interval, polynomial collocation is common. The adjective spectral refers to the representation, not to computing the eigenvalues of an arbitrary matrix.[ref]
Spectral Methods in MATLAB by Lloyd N. Trefethen. Author's description and sample chapters on spectral differentiation and collocation
For periodic data at , the discrete Fourier transform gives coefficients of a trigonometric interpolant. Its derivative is obtained by multiplying coefficient by and transforming back. For nonlinear equations, products can be evaluated on the physical grid, while derivatives are computed in Fourier coordinates. A Fast Fourier transform makes these representation changes efficient.
The grid can confuse unresolved frequencies with resolved ones. With , take . Its exact square isAt the eight grid points, , so the sampled product appears to contain wave number instead of . This is aliasing created by the nonlinear product, even though the input wave number was representable. Additional grid resolution, padding or appropriate filtering is needed when such products are used to evolve retained modes.
For sufficiently smooth solutions, spectral representations can converge rapidly as resolution increases. Discontinuities, boundary incompatibilities and unresolved fine structure change that behavior. A pseudospectral method therefore needs checks on both approximation error and the nonlinear operations performed on its grid.
Quefrency 2026-11-05
Quefrency is the independent coordinate of a cepstrum. When a cepstrum is obtained by an inverse Fourier transform of a logarithmic magnitude spectrum expressed as a function of frequency in hertz, its quefrency coordinate has units of time. A repeated pattern across frequency can consequently appear at the corresponding reciprocal spacing on the quefrency axis.[ref]
Spectral Audio Signal Processing by Julius O. Smith III. Spectral Envelope Extraction, Cepstral Windowing, equation 11.2: inverse transform of log spectral magnitude
For an -point discrete Fourier transform with sampling rate , bin spacing is . The inverse-transform coordinate at index has quefrencyWith , index 40 represents . An ideal echo delayed by 40 samples generates spectral ripples spaced by and a cepstrum contribution at that delay, with further contributions at its multiples. The cepstrum's real-valued convention can also produce mirrored peaks at negative quefrencies.
A quefrency peak is therefore not a -period oscillation of the original waveform by definition. Depending on the signal, it might reflect an echo or a fundamental frequency near . Interpretation requires a model of how the spectral repetition arose.
Scalloping loss 2026-11-05
Scalloping loss is the underestimate of an isolated sinusoidal amplitude caused by measuring it only at the nearest sampled discrete Fourier transform frequency, after correcting the window’s coherent amplitude scale. An off-grid tone is evaluated away from the maximum of the window response. This differs from the coherent gain of a window, which describes the response at the correctly centered frequency. The instrument manual treats amplitude scaling and off-bin errors separately.[ref]
Let be a finite real window with positive sum, and let , where is the nearest unpadded DFT bin and . Write . The coherent-gain-corrected bin magnitude relative to isHere is a positive loss when . The half-bin amplitude response of a window evaluates this ratio at the largest nearest-bin offset. Other tones, noise and the negative-frequency image of a real sinusoid can also affect a measured peak; the derivation isolates one complex tone.
For a rectangular window, its geometric-sum transform givesFor , the half-bin ratio is about and the loss about . An amplitude-one tone exactly centered on a bin is recovered as one, while the same tone shifted by half a bin gives only about at either nearest bin. Dividing by coherent gain cannot remove this offset dependence.
For the periodic Hann window, usewhere is the rectangular response. At , this gives a half-bin ratio about , or loss. The smaller nearest-bin error comes with a wider main lobe and a larger equivalent noise bandwidth; window choice affects several measurement properties at once.
Zero padding reduces the nearest-grid offset without changing the measured record. Padding to points makes the nearest offset at most in original-bin units. With and , the rectangular response at that worst offset is about , a loss of only . This is denser sampling of the same discrete-time Fourier transform, not extra physical frequency resolution. A fitted peak can reduce a grid error too, but its signal model and noise sensitivity must be stated.
A proposed analyzer test holds tone amplitude fixed while sweeping frequency through one bin interval, retaining record length, sampling rate and window. Divide out coherent gain, plot the measured peak versus fractional-bin offset, and compare with the exact response above. Include phase and nearby-tone checks for a real signal. Summing spectral powers instead answers an energy question and requires its own bandwidth normalization; it should not silently replace this single-bin amplitude definition.
Semidiscrete Fourier transform Created 2026-10-24 Updated 2026-10-31
For a sequence indexed by the integers, its semidiscrete Fourier transform is the displayed Fourier series in . For square-summable data the series is interpreted in the L2 norm. Its inversion and Parseval identity areThe physical-frequency convention uses and on . This is distinct from the discrete Fourier transform of a finite vector. Translation-invariant finite difference operators become Fourier multipliers, making Fourier stability analysis possible.
Spectral leakage bias in harmonic distortion measurements occurs when a finite record spreads a strong component into bins interpreted as distinct harmonics. A waveform can have zero physical total harmonic distortion while a naive FFT-bin ratio reports otherwise. Confining a sinusoid to a finite interval creates spectral sidelobes; the pinned primary guide derives this leakage from the finite-time Fourier transform.[ref]
SciPy 1.16.2 documentation. Signal Processing guide, Spectral Analysis, equations 1–3 and window comparison
For an exact discrete calculation, take , where is the number of cycles in the record. With the unscaled forward discrete Fourier transform, a finite geometric sum giveswherewhenever the denominator is nonzero, with the finite-sum limit elsewhere. Integer-cycle coherent sampling makes the unwanted integer bins cancel; a noninteger cycle count generally does not. The negative-frequency contribution also matters because the input is real.
For an original pure-tone example, let , , and . Its true higher-harmonic amplitudes are zero. Yet choosing the nearest bins , , and for the fundamental, second and third harmonic givesA naive result would be about distortion from this undistorted sinusoid. This is an exactly specified record calculation, not an instrument's measured distortion floor.
A window reduces some sidelobes at the cost of a broader main lobe and a changed amplitude normalization. Its coherent gain of a window must be treated consistently, and one cannot assume that one selected bin captures a noncoherent tone's full amplitude. Zero padding samples the same finite-record spectrum more densely; it does not restore missing observation time or remove leakage.
A measurement can instead synchronize the source and acquisition for an integer number of cycles, fit a justified sinusoidal model, or use a validated window/band-integration method. The finite-record phasor extraction with coherent sampling gives a particularly transparent exact case. Calibrated receiver response and actual harmonic coverage remain necessary, as in the primary Anritsu apparatus.[ref]
Total Harmonic Distortion Measurements by Anritsu. Printed pp. 2–3, definitions and frequency-dependent receiver calibration
Power spectral density and squared-amplitude spectrum outputs also have different units; an arbitrary square root of a density bin is not a calibrated harmonic amplitude.[ref] Uniform forcing of a periodic heat equation 2026-10-25
For a spatially constant PDE source term , subtract its time integral from . The result obeys the homogeneous heat equation with the same initial condition. This proves the displayed formula and shows that uniform heating changes only the zero Fourier mode. In an unnormalised discrete Fourier transform, a constant increment adds to the zero-frequency coefficient.
