Skip to content
Tutorials Center
My learning

Topics

Lesson 14 of 36 ยท Fourier Series

Introduction to Fourier Series

Understand why periodic signals are sums of harmonics, learn the trigonometric Fourier series with its coefficient formulas, and rebuild a square wave step by step in Python.

Joseph Fourier's big idea: any reasonable periodic signal is a sum of sines and cosines whose frequencies are integer multiples of one base frequency. A violin note, a square clock pulse and an ECG heartbeat all decompose into simple tones. The decomposition is useful for two reasons. It tells you what frequencies a signal contains, and because LTI systems treat each frequency separately (they scale and shift sinusoids), it makes system analysis a matter of multiplication.

Harmonics

Let x(t) be periodic with fundamental period T0, so f0 = 1/T0 and w0 = 2 pi / T0. The harmonics are sinusoids at w0, 2 w0, 3 w0, ...: the first harmonic is the fundamental, the second has twice the frequency, and so on. All of them repeat after T0, so any combination of them does too, and a constant (DC) term fits the same pattern.

The trigonometric Fourier series

x(t) = a0 + sum over k >= 1 of [ a_k cos(k w0 t) + b_k sin(k w0 t) ]

with coefficients, integrating over any one period:

  • a0 = (1/T0) integral of x(t) dt (the average value)
  • a_k = (2/T0) integral of x(t) cos(k w0 t) dt
  • b_k = (2/T0) integral of x(t) sin(k w0 t) dt

Why do these formulas work? Because sines and cosines at different harmonics are orthogonal: the integral over one period of cos(k w0 t) cos(m w0 t) is zero when k != m (and T0/2 when k = m). Multiplying by cos(k w0 t) and integrating therefore isolates the coefficient a_k, exactly like taking a dot product with one axis of a coordinate system.

Python Orthogonality of harmonics, numerically

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.

Worked example: the square wave

Take the odd square wave of period T0: x(t) = +1 for 0 < t < T0/2 and -1 for T0/2 < t < T0. It is an odd signal, so every a_k (and a0) vanishes, and

b_k = 4 / (pi k) for odd k, b_k = 0 for even k.

Hence x(t) = (4/pi) [ sin(w0 t) + (1/3) sin(3 w0 t) + (1/5) sin(5 w0 t) + ... ].

The even-odd symmetry from Even, Odd and Periodic Signals saved half the work: odd signals need only sines, even signals only cosines.

Python Computing the coefficients numerically

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.

Building the signal from its harmonics

Adding more harmonics improves the approximation. With K terms the partial sum x_K(t) is the best possible approximation (in the least-squares sense) by harmonics up to order K.

Python Square wave from harmonics

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 RMS error shrinks as harmonics are added. Near the jumps, however, the partial sums overshoot; that is the Gibbs phenomenon, in Common Fourier Series and Gibbs Phenomenon.

Compact form

Combining a_k cos + b_k sin into one sinusoid gives c_k cos(k w0 t + theta_k) with c_k = sqrt(a_k^2 + b_k^2) and theta_k = -atan2(b_k, a_k). The picture is a line spectrum: a bar of height c_k at each frequency k f0. The next lesson shows that complex exponentials make this form much neater.

Dirichlet conditions

A periodic signal has a convergent Fourier series if, over one period, it is absolutely integrable, has finitely many maxima and minima, and finitely many finite discontinuities. All practical signals satisfy them. At a jump the series converges to the midpoint of the two sides.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. The harmonics of a signal with fundamental frequency 50 Hz are at:

    Harmonics are integer multiples of the fundamental frequency.
  2. 2. Why can multiplication by cos(k w0 t) and integration isolate a_k?

    Orthogonality makes every term except the k-th integrate to zero.
  3. 3. An odd periodic signal has which Fourier coefficients equal to zero?

    Odd signals contain only sines, so the cosine coefficients and the average vanish.
  4. 4. The odd square wave of amplitude 1 contains which harmonics?

    Even harmonics cancel by half-wave symmetry; odd harmonics fall off as 1/k.
  5. 5. At a jump discontinuity the Fourier series converges to:

    The series gives the average of the left and right limits.

Summary

  • Periodic signals are sums of harmonics at multiples of f0 = 1/T0.
  • Coefficients come from integrals over one period, made possible by orthogonality.
  • Odd signals need only sines, even signals only cosines.
  • The odd square wave is (4/pi) sum over odd k of sin(k w0 t) / k.
  • More harmonics reduce the error; convergence follows the Dirichlet conditions.

Next: Complex Exponential Fourier Series