Math With AmarA C A D E M Y
All math animations

University · Fourier analysis

Build a square-like wave from sine waves

Add odd harmonics and watch a finite Fourier sum approach a square wave, with visible overshoot near its jumps.

Predict what will happen, press Play, then pause and explain what changed. Every control also works without playback.

Watch the relationship

Paused
Build a square-like wave from sine waves. Highest harmonic: 7. Phase t (radians): 0. Sum at x = π/3: 1.04Finite sum · 4 odd harmonicsa−a2πTeal: finite sum · Dashed: ideal square wave
This is a finite Fourier partial sum, not an exact square wave or a physical wave equation solver. The ideal target has value zero at its jumps, matching the midpoint limit. The phase t runs from 0 to 2π; f is a positive integer.

Starts paused. Play once, pause anywhere, or use Step to inspect the mathematics. Playback stops when this panel leaves the screen.

Make it your experiment

Change one value. Notice what follows.

The controls adjust the model. Numbers below describe the current frame. Decimals are rounded.

Highest harmonic
7
Phase t (radians)
0
Sum at x = π/3
1.04

HD animation studio

From experiment to screen.

Present a crisp Canvas scene, save a full-HD image, or capture your model as a silent video.

Understand what you are seeing

The idea behind the motion.

Complicated periodic shapes can be assembled from simple sinusoidal components. For a symmetric square wave, only odd harmonics appear. Increasing the number of terms sharpens transitions, but a finite sum is always smooth and cannot reproduce a jump exactly.

A relationship to keep

Sₙ(x, t) = (4a/π) Σⱼ₌₀ⁿ⁻¹ sin((2j+1)(fx−t))/(2j+1)

Read the symbols alongside the explanation. A diagram shows the relationship; the assumptions tell you when it applies.

  1. STEP 1

    Begin with a fundamental

    With one term, the curve is a single sine wave. The coefficient 4a/π is chosen for the Fourier representation of the target square wave.

  2. STEP 2

    Add odd harmonics

    Each new term has an odd multiple of the fundamental frequency and a smaller coefficient. All terms move with the same translating pattern because their phases scale with their harmonic number.

  3. STEP 3

    Notice the limitation

    The dashed amber target jumps between −a and +a. The teal finite sum overshoots near those jumps. Adding terms narrows that region but does not make the limiting overshoot height vanish: this is the Gibbs phenomenon.

Your turn to explain

Make a prediction. Test your reasoning.

With N = 3, which harmonic numbers appear?

Use the values specified in the question. Reset restores the initial values for this investigation.

Compare your explanation

1, 3, and 5, with coefficients 4a/π, 4a/(3π), and 4a/(5π). N counts terms, not the largest harmonic number.

Connect the animation to a worked example and practice questions.