Skip to content
Tutorials Center
My learning

Topics

Lesson 7 of 46 · Signals and Spectra

Fourier series

Write periodic signals as sums of harmonics, derive the square wave series, see the Gibbs phenomenon and use Parseval's relation to compute power.

A clock signal, a tone from a synthesizer, the output of a rectifier: all are periodic, repeating exactly every T0 seconds. The Fourier series says that any such signal (under mild conditions) is a sum of sinusoids whose frequencies are whole multiples of the repetition rate f0 = 1 / T0. It turns a waveform into a short list of numbers, and that list is the signal's spectrum.

Partial sums of the square wave series with one, two and eight terms, and a bar chart of amplitudes 4 over pi n
Adding odd harmonics builds up the square wave; amplitudes fall as 1/n.

What you will learn

  • The trigonometric and complex forms of the Fourier series.
  • How to find the series of a square wave and read its spectrum.
  • What the Gibbs phenomenon is and why it does not go away.
  • How to compute power with Parseval's relation.

Key terms

  • Fundamental frequency f0 = 1/T0: the repetition rate of the signal.
  • Harmonic: a component at n · f0 for integer n.
  • Fourier coefficient cn: the complex amplitude of harmonic n.
  • Line spectrum: a plot of coefficients as vertical lines at n · f0.
  • Parseval's relation: total power equals the sum of the powers of the harmonics.

The series

For a periodic x(t) with period T0, the trigonometric form is

x(t) = a0 + Σ [ an cos(2π n f0 t) + bn sin(2π n f0 t) ], summed over n = 1, 2, 3, ...

with a0 the average value (the DC level). The coefficients come from averaging over one period: an = (2/T0) ∫ x(t) cos(2π n f0 t) dt and bn = (2/T0) ∫ x(t) sin(2π n f0 t) dt. The idea behind the formulas: a sine of a different frequency averages to zero against x(t), so the integral picks out only the matching component.

The complex form is neater. With j = √−1 and Euler's identity e^(jθ) = cos θ + j sin θ:

x(t) = Σ cn · e^(j 2π n f0 t) for all integers n, and cn = (1/T0) ∫ x(t) e^(−j 2π n f0 t) dt.

For a real signal, c(−n) is the complex conjugate of cn, so the spectrum has a mirror image at negative frequencies, and the amplitude of the real sinusoid at n f0 is 2|cn|. The magnitude |cn| and the angle of cn form the amplitude and phase spectra.

Worked example: the square wave

Take an odd square wave of amplitude ±A, period T0, which is +A for the first half period and −A for the second. By symmetry a0 = 0 and every an = 0. The integral for bn gives bn = 4A / (π n) for odd n, and 0 for even n:

x(t) = (4A/π) · [ sin(2π f0 t) + (1/3) sin(2π 3 f0 t) + (1/5) sin(2π 5 f0 t) + ... ]

With A = 1 and f0 = 1 kHz: the fundamental has amplitude 4/π ≈ 1.273 at 1 kHz, the third harmonic 1.273/3 ≈ 0.424 at 3 kHz and the fifth 0.255 at 5 kHz. There is no second or fourth harmonic. Notice what this says about bandwidth: the sharper the edges, the more high harmonics you need, and the amplitudes fall only as 1/n. A square wave never fits in a finite bandwidth.

Power and Parseval

The average power of a periodic signal (across a 1 Ω resistor) can be computed in time, as the mean of x², or in frequency, as the sum of harmonic powers:

P = (1/T0) ∫ x²(t) dt = Σ |cn|² (over all n).

For the ±1 square wave the time-domain power is simply 1, because x² = 1 everywhere. The fundamental alone carries (1.273)²/2 ≈ 0.811 of it, 81 %. Adding the third harmonic (0.424²/2 ≈ 0.090) and the fifth (0.255²/2 ≈ 0.032) brings the total to about 93.3 %. That is why a filter that keeps only the first three harmonics passes most of the power even though the waveform looks rounded.

Gibbs phenomenon

Near the jump of a square wave, the partial sums overshoot the true value by about 9 % of the jump height (a jump of 2 gives an overshoot of about 0.18 above 1) and the overshoot does not shrink as you add terms; it only becomes narrower. This was noted by Henry Wilbraham in 1848 and rediscovered by J. Willard Gibbs in 1899. In practice it is the ringing you see on a poorly filtered square wave on an oscilloscope.

Common misconceptions

"More terms mean the overshoot disappears." The overshoot width shrinks, its height stays near 9 % of the jump.

"Only the amplitude matters." The phases of the harmonics determine the shape. The same amplitudes with scrambled phases give a different waveform with the same power spectrum.

"The series only works for sine waves." It works for any periodic signal with finite energy per period.

Try it

The first example adds odd harmonics and measures the overshoot at the jump. Change terms to see the ringing narrow while its height stays.

Python Synthesize a square wave

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The second example gets the spectrum numerically and checks Parseval's relation: the time-domain power must equal the sum of harmonic powers.

Python Check Parseval for a square wave

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check · 5 questions

of 5 answered You scored / 5 · perfect!

  1. 1. A periodic signal has period 2 ms. Its fundamental frequency is

    f0 = 1 / T0 = 1 / 0.002 s = 500 Hz.
  2. 2. Which harmonics does an odd square wave contain?

    By symmetry, the square wave has no even harmonics; the odd ones have amplitude 4A/(πn).
  3. 3. The fundamental of a ±1 V square wave has amplitude

    b1 = 4A/π with A = 1.
  4. 4. What does the Gibbs phenomenon tell us?

    The overshoot becomes narrower but not smaller.
  5. 5. Parseval's relation states that

    Total power can be computed either in the time domain or by summing |cn|².

Summary

  • A periodic signal is a sum of harmonics at n · f0.
  • Coefficients come from averaging against sinusoids; in complex form cn = (1/T0) ∫ x e^(−j2πnf0t) dt.
  • The ±A square wave has only odd harmonics with amplitudes 4A/(πn).
  • Parseval: P = Σ|cn|²; Gibbs: ~9 % overshoot never vanishes.

Next: Fourier transform