TactivergeLite

Lite / Engineering Complex Systems / 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 · Full interactive version

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.

Predict

Which harmonics appear in a symmetric square wave of frequency f₀?

  1. All of them: f₀, 2f₀, 3f₀, …
  2. Only odd ones: f₀, 3f₀, 5f₀, …
  3. Only even ones
  4. Only f₀
Guess first, then reveal

Only odd harmonics. The square wave's two halves are mirror images (x(t + T₀/2) = −x(t)), and even harmonics can't have that symmetry, so they cancel. The bar chart in the builder shows the even slots empty.

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?

What the interactive shows (text version)

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.

You can also open the interactive on the full site when you have a faster connection.

Watch (optional)

Watch for: 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.

“But what is a Fourier series? From heat flow to drawing with circles | DE4” by 3Blue1Brown (opens YouTube; streaming video uses a lot of data)

The video is optional. Everything you need is in this lesson's text.

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

Intuitive

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.

Technical

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.

Mathematical

Σ 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.

Applied

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

Practice

Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.

Practice 2. What is the amplitude of the 4th harmonic of a symmetric square wave?

%

Practice 5. You add more and more harmonics. What happens to the overshoot near each jump?

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?

Reflect

Why does a sharp edge in time need high frequencies? Explain in your own words, without the formula.

Write your answer on paper or in your own notes. Lite never stores what you write.

← Seeing a signal's ingredientsThe DFT: asking 'how much of this wave?' →