Parseval's Theorem Simulator Back
Signal Processing Simulator

Parseval's Theorem — Energy Conservation in Time and Frequency

Verify in real time that the time-domain energy of a discrete signal equals its frequency-domain energy under the DFT, using three signal families: sinusoid, rectangular pulse and Gaussian.

Parameters
Signal type (0=Sinusoid 1=Rect pulse 2=Gaussian)
Amplitude A
Frequency f₀ — for type 0
bin
Sample count N
samples

At the defaults (sinusoid, A=1, f₀=10, N=512), E_t = E_f = 256 exactly, and the relative error is at the floating-point round-off level (about 1e-12).

Results
Time-domain energy E_t = Σ|x|²
Frequency-domain energy E_f = (1/N)Σ|X|²
Relative error |E_t-E_f|/E_t
Peak frequency bin
Time signal x[n] and power spectrum |X[k]|²/N

Top: time signal x[n] (blue, first 200 samples) — Bottom: PSD = |X[k]|²/N (red, k = 0..N/2, peak highlighted)

Theory & Key Formulas

Parseval's theorem states that the total energy of a signal is conserved between the time and frequency domains. For a discrete signal x[n] of length N:

Discrete Fourier transform (DFT):

$$X[k] = \sum_{n=0}^{N-1} x[n]\, e^{-j 2\pi k n / N}$$

Parseval's theorem (standard DFT normalization):

$$\sum_{n=0}^{N-1} |x[n]|^2 = \frac{1}{N}\sum_{k=0}^{N-1} |X[k]|^2$$

Power spectral density (periodogram estimate):

$$\mathrm{PSD}[k] = \frac{|X[k]|^2}{N}$$

For a pure sinusoid $x[n] = A\cos(2\pi f_0 n / N)$ the time-domain energy is $\sum |x[n]|^2 = N A^2 / 2$, because the average of $\cos^2$ is 1/2.

What is the Parseval's theorem simulator?

🙋
I've seen Parseval's theorem in the textbook, but the formula on its own doesn't really click for me. What's it actually good for?
🎓
In one line: it guarantees that the total energy of a signal comes out the same whether you measure it in time or in frequency. Look at the defaults (sinusoid, A=1, N=512) in the simulator. E_t is 256, E_f is also 256, and the relative error is essentially zero. Since the mean of $\cos^2$ is 1/2, the theoretical value is exactly $N \cdot A^2/2 = 512 \cdot 1/2 = 256$. Compute it two completely different ways and you get the same answer — that's the punch line.
🙋
Yeah, both 256 exactly! The relative error shows about 1e-13. What's that tiny number?
🎓
That's floating-point round-off. In theory it should be zero, but adding N numbers each with about 2⁻⁵² rounding error accumulates a tiny mismatch. Conversely, 1e-13 is the evidence that Parseval is holding to the limit of what double precision can detect. Try changing the amplitude A to 2 — both E_t and E_f jump together to about 1024 (= N·A²/2). They never drift apart.
🙋
Right! And switching to type 1 (rectangular pulse), the energies drop together — but they still agree.
🎓
The rectangular pulse only puts amplitude A=1 on the central N/8 samples, so the time-domain energy is N/8 = 64. The bottom plot shows a wide sinc-like spectrum, and when you sum the whole thing and divide by N you get 64 back. The signal shape changed completely, but the total energy on each side still balances. That's the power of Parseval — it doesn't care what the signal looks like.
🙋
The Gaussian (type 2) has a much smoother spectrum. Where do people use this in practice?
🎓
Vibration and acoustic measurements are classic examples. To get the total vibration energy from an accelerometer signal, you can either integrate the squared waveform in time or FFT it and sum the spectrum — Parseval guarantees the two routes agree. Even better, if you only want the energy in, say, 100–200 Hz (band power), you sum the spectrum over that range. That's exactly equal to bandpass-filtering in time and then taking the energy. It's an incredibly practical identity.

Frequently asked questions

There are three common DFT conventions. (1) Unnormalized forward (this tool, NumPy fft, MATLAB fft): Σ|x|² = (1/N)·Σ|X|². (2) 1/N on the forward transform: Σ|x|² = N·Σ|X|². (3) Symmetric 1/√N (SciPy norm='ortho'): Σ|x|² = Σ|X|². Parseval holds in all of them, only the constant differs. Check the documentation of any FFT library before relying on the constants.
The DFT of a real signal is Hermitian symmetric: X[N-k] equals the complex conjugate of X[k], so |X[k]|² = |X[N-k]|². A cosine contains both +f₀ and -f₀ components, which appear symmetrically at k=f₀ and k=N-f₀. The lower plot displays only k=0..N/2, so you see the lower peak (k=10); the peak-bin readout reports that one.
Strictly speaking, the "power spectrum" is the power per discrete bin (|X[k]|²/N²) and the "power spectral density" (PSD) is the power per unit frequency (|X[k]|²/(N·Δf), giving |X[k]|²/fs when Δf=fs/N). In the energy-conservation context this tool uses the normalized periodogram |X[k]|²/N, which is convenient because (1/N)·Σ|X|² equals the time-domain energy directly. For physical-unit work (V²/Hz, g²/Hz), divide by the sampling frequency.
The continuous version (Plancherel's theorem) is ∫|x(t)|²dt = ∫|X(f)|²df, where integrals replace sums. In the discrete case the integrals become sums, and the 1/N factor appears according to the DFT normalization. The physical content is identical — energy is conserved between time and frequency — but the finite-length discrete version is subject to spectral leakage at the frame boundary. Parseval itself still holds exactly: leakage redistributes energy across bins but the total stays the same.

Real-world applications

Vibration and acoustic measurement: To get the overall RMS of a vibration or sound signal, you can square-and-sum the time waveform or sum the spectrum from the FFT, and Parseval guarantees the two routes give identical numbers. Octave-band and 1/3-octave analyses select the energy in specific frequency bands directly from the spectrum, which corresponds exactly to bandpass-filtering in time.

Signal-to-noise ratio in communications: Radio, optical and acoustic communications measure the signal-to-noise ratio by computing signal and noise power either from the time waveform or by separating signal and noise bands in the spectrum. The two approaches are Parseval-equivalent, which is why MATLAB's snr() and similar tools mix time- and frequency-domain reasoning interchangeably.

Image processing and compression: JPEG and MPEG transform images into the frequency domain (DCT or DFT) and discard high-frequency components with little energy. PSD tells you which coefficients hold the energy and so should be kept. Combined with the Wiener-Khinchin theorem, signals with strong autocorrelation have concentrated PSDs and compress especially well.

Quantum mechanics: Parseval is a unitary norm-preservation property. In quantum mechanics, the position-space probability density |ψ(x)|² and momentum-space density |φ(p)|² satisfy ∫|ψ|²dx = ∫|φ|²dp. This guarantees that the total probability stays equal to 1 whether you compute it in position or momentum space — a foundational consistency of the theory.

Common misconceptions and pitfalls

The most common mistake is to forget the 1/N normalization factor. NumPy and MATLAB use the unnormalized forward DFT, so the raw spectral sum Σ|X[k]|² is N times the time-domain energy. You must divide by N before comparing. If you use SciPy with norm='ortho', the symmetric convention makes Σ|X[k]|² equal to the time-domain energy directly. Always check the library's convention before mixing energies across domains.

Another common pitfall is to ignore the high variance of the raw periodogram. The PSD displayed here, |X[k]|²/N, is a single-frame estimate. For random or noisy signals, each bin fluctuates wildly around its true value. Production code uses Welch's method (averaging overlapping segments), Bartlett's method (averaging non-overlapping segments) or parametric (AR) modelling to reduce the variance. Parseval itself holds for any of these estimators, but the reliability of an individual bin is a separate question.

Finally, do not believe that spectral leakage breaks Parseval. When the signal frequency does not fall exactly on a DFT bin (or you skip the window function), energy "leaks" into nearby bins. This makes individual bin values inaccurate, but if you sum over all bins you still get the same answer as Σ|x|². Parseval is exact; leakage only redistributes the energy across bins, never destroys it. You can see this here by switching to the Gaussian signal: its spectrum is broad, yet E_t and E_f still match to machine precision.