Skip to content
Tutorials Center
My learning

Topics

Lesson 10 of 38 ยท DFT and FFT

Fourier Series and Complex Exponentials

Build intuition for the Fourier transform: phasors and complex exponentials, Fourier series, the square wave from odd harmonics, the Gibbs effect and orthogonality.

The central idea of this chapter is that any signal can be written as a sum of sine waves. This is surprising (how can smooth sines make a sharp square wave?) and also extremely useful, because sine waves pass through LTI systems in a very simple way: they come out as sine waves of the same frequency, only scaled and shifted. So if you split a signal into sines, filter each one by a number, and add them up, you have filtered the signal. Before the discrete tools, let us see the idea with the Fourier series.

Phasors and complex exponentials

A cosine with amplitude A, frequency f and phase phi is the real part of a rotating arrow in the complex plane:

A cos(2 pi f t + phi) = Re{ A e^(j phi) * e^(j 2 pi f t) }

The constant A e^(j phi) is the phasor: one complex number holding amplitude (its length) and phase (its angle). The factor e^(j 2 pi f t) is a unit arrow spinning counterclockwise f times per second. Using complex exponentials turns trigonometric identities into simple multiplication, which is why the DFT is written with them.

Euler's formula links them: e^(j x) = cos x + j sin x, and a real cosine is the sum of two counter-rotating arrows:

cos x = (e^(j x) + e^(-j x)) / 2

That second arrow is why a real signal has negative frequencies that mirror the positive ones.

Python Phasors add like arrows

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.

Fourier series: periodic signals

A periodic signal with fundamental frequency f0 is a sum of harmonics at f0, 2 f0, 3 f0, ... with the right amplitudes and phases (plus an average value). For a square wave switching between +1 and -1 the series has only odd harmonics:

square(t) = (4/pi) * [ sin(w0 t) + sin(3 w0 t)/3 + sin(5 w0 t)/5 + ... ]

Each extra term sharpens the corners. The 1/k decay of the amplitudes says that sharp edges need lots of high-frequency content.

Python Build a square wave from odd 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 falls steadily as terms are added. Look at the plot near the jumps: the sum overshoots by about 9 % of the jump, and the overshoot does not shrink however many terms you add; it only gets narrower. This is the Gibbs phenomenon.

Other waveforms

Different shapes have different harmonic recipes:

Waveform Harmonics present Amplitude decay
Square odd only 1/k
Triangle odd only 1/k^2 (smoother, so faster decay)
Sawtooth all 1/k
Python Compute harmonic amplitudes of a triangle wave 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.

The numbers show that even harmonics are absent and that the odd ones follow the 1/k^2 law. The same FFT command you saw in earlier lessons is doing a numerical Fourier series.

Orthogonality: how to find the coefficients

The sines at different harmonics are orthogonal: multiplying two of them together and averaging over a full period gives zero unless they are the same frequency. Therefore, to find how much of frequency k is in a signal, multiply by that sinusoid and average. This "correlate with each candidate frequency" recipe is exactly what the discrete Fourier transform does with N candidates.

Python Orthogonality of complex exponentials

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.

From the series to the transform

A Fourier series needs a periodic signal. Stretch the period to infinity and the harmonics crowd together into a continuous spectrum: that is the Fourier transform. A finite list of samples, which is what a computer has, can be treated as one period of a periodic signal, and the harmonics are then a finite set: the DFT of the next lesson.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which harmonics does a square wave contain?

    A symmetric square wave is the sum of sin(k w0 t)/k for odd k only, times 4/pi.
  2. 2. What is a phasor?

    A e^(j phi) encodes A cos(w t + phi) as a rotating arrow with a fixed starting angle.
  3. 3. What does the Gibbs phenomenon describe?

    Partial Fourier sums overshoot near discontinuities; more terms only narrow the overshoot.
  4. 4. Why are orthogonal sinusoids useful?

    The average of a product of different harmonics is zero, so each coefficient can be found separately.

Summary

  • A phasor A e^(j phi) stores amplitude and phase; cosines are sums of two counter-rotating exponentials.
  • Periodic signals are sums of harmonics; a square wave uses odd harmonics with amplitudes 4/(pi k).
  • Sharp edges require high harmonics, and cutting the series causes the Gibbs overshoot.
  • Orthogonality lets you find each coefficient by correlating with that frequency.
  • The DFT applies the same idea to a finite list of samples.

Next: The DFT from Scratch