Parseval's Identity and Energy
Parseval's identity says that the power of a periodic signal equals the sum of the powers of its harmonics. It is the Pythagorean theorem in an infinite-dimensional space, and it is the justification for reading a spectrum as "how much energy is at each frequency". It also proves some surprising sums, such as .
The identity
For a -periodic with Fourier coefficients :
Why: , and averaging kills every cross term with (orthogonality). Only the squared lengths of the components survive, as for a vector written in an orthonormal basis.
import numpy as np
N = 4096
t = np.arange(N) / N
f = np.where(t < 0.3, 2.0, -0.5) + 0.4 * np.cos(2 * np.pi * 7 * t)
c = np.fft.fft(f) / N # all N coefficients of the sampled period
print("time-domain power :", round(float(np.mean(np.abs(f) ** 2)), 10))
print("sum of |c_k|^2 :", round(float(np.sum(np.abs(c) ** 2)), 10))time-domain power : 1.4820369924
sum of |c_k|^2 : 1.4820369924
For sampled signals the identity is exact (it is the DFT's Parseval relation).
The Basel problem
Apply Parseval to the sawtooth on , whose coefficients are and :
Euler found this sum in 1734 by other means; Parseval makes it a two-line computation.
import numpy as np
k = np.arange(1, 10**6 + 1, dtype=float)
partial = np.sum(1 / k ** 2)
print(f"sum up to 10^6: {partial:.10f}")
print(f"pi^2 / 6: {np.pi ** 2 / 6:.10f}")
print(f"tail estimate 1/10^6: {1e-6:.1e} (difference {np.pi ** 2 / 6 - partial:.2e})")sum up to 10^6: 1.6449330668
pi^2 / 6: 1.6449340668
tail estimate 1/10^6: 1.0e-06 (difference 1.00e-06)
Energy in a band
Parseval lets you measure how much power lies in any group of harmonics, which is how bandwidth and distortion are specified. For a square wave, the first harmonic alone carries % of the power, and the first three nonzero harmonics about 93.3 %.
import numpy as np
odd = np.arange(1, 400001, 2)
powers = (4 / (np.pi * odd)) ** 2 / 2 # power of each sine term
cum = np.cumsum(powers)
for n in (1, 2, 3, 10, 100):
print(f"first {n:3d} odd harmonics: {100 * cum[n - 1]:.2f} % of the power")first 1 odd harmonics: 81.06 % of the power
first 2 odd harmonics: 90.06 % of the power
first 3 odd harmonics: 93.31 % of the power
first 10 odd harmonics: 97.98 % of the power
first 100 odd harmonics: 99.80 % of the power
In software
- The energy of a signal can be computed in either domain, a useful sanity check for FFT code:
np.sum(x**2)equalsnp.sum(abs(np.fft.fft(x))**2) / len(x). - Audio codecs allocate bits per frequency band in proportion to the band's energy and its audibility.
Exercises
Exercise 1: Power of a two-tone signal
What is the average power of ?
Answer
12.5.
Solution
Each sinusoid of amplitude contributes , and orthogonal components add: .
Exercise 2: Energy fraction
What fraction of the power of a square wave lies above the 9th harmonic?
Answer
About 4.0 %.
Solution
The first five odd harmonics (1, 3, 5, 7, 9) carry about 96.0 % of the power (the next exercise computes it), leaving about 4.0 % in harmonics 11 and above.
Exercise 3: Check the fraction (code)
Compute the fraction for Exercise 2 exactly from the series.
Answer
95.96 % below, 4.04 % above.
Solution
import numpy as np
odd = np.arange(1, 10, 2)
below = np.sum((4 / (np.pi * odd)) ** 2 / 2)
print(f"{100 * below:.2f} % below, {100 * (1 - below):.2f} % above")95.96 % below, 4.04 % above
Test yourself
Parseval's identity states that the average power equals…
Parseval is the infinite-dimensional version of…
- the triangle inequality
- the Pythagorean theorem
- the chain rule
- Bayes' rule
Applying Parseval to the sawtooth proves that equals…
- 2