TExcelTAD
Home › Fourier Analysis & Signals › Parseval's Identity and Energy

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 ∑1/k2=π2/6\sum 1/k^2 = \pi^2/6.

The identity

For a TT-periodic ff with Fourier coefficients ckc_k:

1T∫0T∣f(t)∣2 dt=∑k=−∞∞∣ck∣2\frac{1}{T} \int_0^T \lvert f(t) \rvert^2 \, dt = \sum_{k=-\infty}^{\infty} \lvert c_k \rvert^2

Why: ∣f∣2=ffˉ=∑k∑mckcm‾ ekem‾\lvert f \rvert^2 = f \bar{f} = \sum_k \sum_m c_k \overline{c_m}\, e_k \overline{e_m}, and averaging kills every cross term with k≠mk \ne m (orthogonality). Only the squared lengths of the components survive, as for a vector written in an orthonormal basis.

python · try it yourself
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 f(t)=tf(t) = t on [0,1)[0, 1), whose coefficients are c0=1/2c_0 = 1/2 and ck=i/(2πk)c_k = i/(2\pi k):

∫01t2 dt=13=14+2∑k=1∞14π2k2⟹∑k=1∞1k2=π26\int_0^1 t^2\,dt = \frac{1}{3} = \frac{1}{4} + 2\sum_{k=1}^{\infty} \frac{1}{4\pi^2 k^2} \quad\Longrightarrow\quad \sum_{k=1}^\infty \frac{1}{k^2} = \frac{\pi^2}{6}

Euler found this sum in 1734 by other means; Parseval makes it a two-line computation.

python · try it yourself
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 8/π2≈81.18/\pi^2 \approx 81.1 % of the power, and the first three nonzero harmonics about 93.3 %.

python · try it yourself
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) equals np.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 f(t)=3cos⁡(2πt)+4sin⁡(6πt)f(t) = 3\cos(2\pi t) + 4\sin(6\pi t)?

Answer

12.5.

Solution

Each sinusoid of amplitude AA contributes A2/2A^2/2, and orthogonal components add: 9/2+16/2=12.59/2 + 16/2 = 12.5.

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
python · try it yourself
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…

  1. ∣c0∣2\lvert c_0 \rvert^2
  2. ∑k∣ck∣2\sum_k \lvert c_k \rvert^2
  3. ∑kck\sum_k c_k
  4. max⁡k∣ck∣\max_k \lvert c_k \rvert

Parseval is the infinite-dimensional version of…

  1. the triangle inequality
  2. the Pythagorean theorem
  3. the chain rule
  4. Bayes' rule

Applying Parseval to the sawtooth proves that ∑1/k2\sum 1/k^2 equals…

  1. π/4\pi/4
  2. π2/6\pi^2/6
  3. ee
  4. 2