School/□ Systems Engineer/Week 21
A square wave made of curves
A square wave has perfectly sharp corners. Sine waves have none. Yet enough sine waves add up to a square. How many, and what's left over?
About 35 min · 3 goals · Checked by automated tests
1.Why should I care?
Digital clocks and PWM motor drives are square waves, and their sharp edges are made of high harmonics. Those harmonics radiate interference, heat transformers and shape what an oscilloscope must be able to see. Knowing the series tells you exactly how much energy sits at each frequency.
- ◇ State the Fourier series of a square wave: odd harmonics with amplitude 4A/(nπ).
- ◇ Compute harmonic amplitudes and the fraction of power in the first few harmonics.
- ◇ Describe the Gibbs overshoot and why sharp edges need high frequencies.
2.Discover
Start with 1 harmonic, then add them one by one up to 25. Watch the power captured and the peak of the sum. Does the overshoot near the jump get smaller, or only narrower?
Loading the interactive…
Can't use the interactive? Read a description instead
With 1 harmonic the builder draws a sine of peak 1.27 over the square. Adding odd harmonics (3, 5, 7…) fills in the corners; captured power rises from 81 % to about 98 % with 13 terms; the peak near each jump stays about 1.18, a 9 % overshoot of the jump of 2.
3.Checkpoint: guided practice
Check what you just discovered before going on. Hints appear after a wrong answer.
Practice 1
What is the amplitude of the fundamental of a ±1 square wave (3 decimal places)?
Practice 2
What is the amplitude of the 4th harmonic of a symmetric square wave?
4.Predict
Which harmonics appear in a symmetric square wave of frequency f₀?
Guess first. Being wrong here is how the surprise works.
5.Understand
The series
A square wave swinging between +A and −A is x(t) = (4A/π)·[sin ωt + sin 3ωt/3 + sin 5ωt/5 + …]. Harmonic n has amplitude bₙ = 4A/(nπ) for odd n and 0 for even n. The fundamental is 4/π ≈ 1.27 times taller than the square itself.
Power is concentrated low
The square has power A². The fundamental alone carries (4A/π)²/2 = 8A²/π² ≈ 81 % of it; adding the 3rd and 5th reaches about 93 %. So a square wave through a low-pass filter quickly looks like a sine: that is how some cheap sine-wave inverters work.
Gibbs: the overshoot that won't go away
Near each jump the partial sum overshoots by about 9 % of the jump, however many terms you add. More terms make the overshoot narrower, not lower. In practice, ringing near edges in a band-limited system is the same effect: a sharp edge truly needs infinitely high frequencies.
Explain it another way
Each new odd harmonic is a smaller, faster wiggle that fills in more of the corners. You never finish, but you get close enough for any practical purpose.
Coefficients come from correlation: bₙ = (2/T₀)∫ x(t)·sin(nω₀t) dt. For the square, the integral over each half-period gives 2A(1 − cos nπ)/(nπ), which is 4A/(nπ) for odd n and 0 for even n.
Σ over odd n of (4A/(nπ))²/2 = (8A²/π²)·Σ 1/n² (odd n) = (8A²/π²)·(π²/8) = A²: the harmonics carry exactly the square's power, as Parseval's theorem requires.
A 100 MHz digital clock has strong harmonics at 300 and 500 MHz. Circuit-board designers slow the edges deliberately and add filtering so those harmonics don't fail electromagnetic-compatibility tests.
Worked example 1
A ±5 V, 1 kHz square wave drives a speaker. What is the amplitude of the 3 kHz component?
n = 3: b₃ = 4 × 5/(3π) ≈ 2.12 V.
Common mix-ups
- Enough harmonics make a perfect square wave with no overshoot.
✓ The partial sums always overshoot by about 9 % near jumps; only the width shrinks. - The fundamental of a ±1 square wave has amplitude 1.
✓ It is 4/π ≈ 1.27: taller than the square, with the harmonics trimming it back down.
6.Watch
→ Look for how each coefficient is found by 'filtering out' one rotating component: the same correlation idea as the DFT next lesson.
Builds sharp-cornered functions, including a square wave, out of rotating sinusoids, and shows where the 4/(nπ)-style coefficients come from.
24 min 47 s · captions on YouTube · source
Nothing loads from YouTube until you press play.
The video is optional: everything you need is also in the lesson text and the interactive.
7.Practice on your own
Practice, not a test. Wrong answers get a hint and another try.
Practice 3 · a fresh version every time
A square wave swings between +2 and −2 at f₀ = 200 Hz. What is the amplitude of its harmonic number n = 5 (the component at 1000 Hz)? Give 3 decimal places.
Practice 4
What percentage of a square wave's power is in its fundamental alone (8/π² as a percentage, 1 decimal place)?
Practice 5
You add more and more harmonics. What happens to the overshoot near each jump?
8.Apply it
A PWM motor driver produces a 20 kHz square wave. Which harmonics fall in the human hearing range (up to about 20 kHz)? Why do some cheap drivers whine, and what happens if you move the PWM frequency to 8 kHz?
9.Reflect
Concepts: Frequency domain and the Fourier transform