I’ve been having some fun visualizing Fourier series. Here are three periodic functions:

The first is a sawtooth. The second is a sampled-and-held version of the same; these are analogous to what might go into and come out of a digital recording system, before any filtering. The third looks quite different but is related: in the second function the height of each step samples the first, while in the third the width of each pulse samples the first. It’s analogous to what one gets from a PWM (pulse width modulation) circuit, like the one that provides “analog” outputs on an AVR microcontroller.

Even knowing intellectually the connection between the three, I find it viscerally surprising that the first several terms of the Fourier series for all three are very similar. Sum the first four terms of each and you get the functions in blue:

Here are six terms:

They’re still pretty similar, though the third is getting more wiggly. This illustrates how you can put the output of a DAC (digital to analog converter) or a PWM through a low pass filter and reproduce the original analog signal, or at least a bandlimited version thereof.

Add the seventh term and you see the third function start to go its separate way from the first two:

The underlying sawtooth amplitude is still visible but the wiggles are starting to dominate. Now the eighth term:

Now the sawtooth amplitude is starting to disappear. At 12 terms the second function is noticeably more jagged than the first:

With 16 terms the stairsteps of the second function and the varying pulse widths of the third are becoming evident:

Here’s 32 terms:

and 64:

They start out so similar and end up so different. Hard work and perseverance, grim determination of the soul?

Here’s an animation of the whole thing.

### Like this:

Like Loading...

*Related*

Hi, I would like to know more about how the three fourier series sum up to give three different waveforms TECHNICALLY. Could you give us more technical/mathematical insights of using PWM and low-pass to achieve DAC ?