Fourier Series Building a square wave

Can smooth waves add up to a shape with sharp corners? Keep adding sine waves and watch a square wave take shape.

=
Think of the waves as voices in a choir. Each contributes a smooth curve; with the right proportions, their sum gets closer to a square wave. Any finite number still leaves a continuous curve, with no true jumps.

1Try it

Build the wave, one term at a time

Target: square wave (dashed) Your sum: first N sine waves Shading: gap between the curves Highest term: shown as N changes

2Look closer

Watch what changes

  1. Start with 1 wave. You have a smooth sine curve, still far from the square target.
  2. Increase the count to 8. The shape looks more square. Now look near a jump: the bump gets narrower, but it does not disappear.

3Where it shows up

Looking inside a signal

4The equation

The sum behind the shape

Explore the equation

square wave(t) ≈ (4/π)·[ sin(ωt) + ⅓sin(3ωt) + ⅕sin(5ωt) + … ]

Hover over a symbol, or tap it, to see what it contributes to the sum.

Each term inside the brackets is a sine wave. N is the slider setting: keep the first N terms.

ω
The fundamental angular frequency sets the rate of the first, slowest sine wave. It also determines the period of the square wave.
1, ⅓, ⅕, …
The frequencies are 1, 3, 5, … times the fundamental: only odd multiples. The fractions make each successive wave smaller, so the higher-frequency terms help sharpen the corners.
4/π
The overall scale corresponds to the target square wave at ±1. A finite sum is not confined to those levels. With N = 1, for example, its peak is 4/π ≈ 1.273.
N
Your slider chooses how many terms to keep. Increasing N adds higher-frequency terms and makes the corners look sharper.

As you add more terms, the overshoot near a jump approaches 8.949% of the jump size. This is the Gibbs phenomenon. Here the wave jumps from −1 to +1, a change of 2, so the peak approaches 1.179: about 17.9% above the +1 level. The canvas label “+18%” uses that level as its reference. A finite sum gives a slightly different percentage. More terms move the bump closer to the jump; they do not remove the limiting overshoot.

Sources and scope

MIT: Gibbs’ phenomenon and overshoot as a fraction of the jump

This interactive model works within the conditions described here. Use the picture to explore the equation, keeping those conditions in view.