Differential Equations, Interactive EditionXYZ Homework Edition

⇩ Download ▾

3.2 Square-Wave Forcing

Throw the switch on and off forever and you get the simplest periodic forcing there is: the square wave. With period 2π2\pi, let sq(t)\mathrm{sq}(t) equal π/4\pi/4 on the first half-period and π/4-\pi/4 on the second. (The odd-looking amplitude π/4\pi/4 is chosen to make every coefficient below a clean unit fraction.) In the language of the last section it is an infinite train of switches,

s q ( t ) = π 4 ( 1 2 u π ( t ) + 2 u 2 π ( t ) 2 u 3 π ( t ) + ) , \mathrm{sq}(t) = \frac{\pi}{4} \left( 1 - 2u_{\pi}(t) + 2u_{2\pi}(t) - 2u_{3\pi}(t) + \cdots \right),

and its transform costs one geometric series: each delayed switch contributes its exponential tag, and

{ s q } ( s ) = π 4 s ( 1 2 e π s + 2 e 2 π s ) = π 4 s · 1 e π s 1 + e π s , \mathcal{L}\{\mathrm{sq}\}(s) = \frac{\pi}{4s} \left( 1 - 2e^{-\pi s} + 2e^{-2\pi s} - \cdots \right) = \frac{\pi}{4s} \cdot \frac{1 - e^{-\pi s}}{1 + e^{-\pi s}},

a closed form paying for infinitely many switches at once. That is the time ledger: the wave described by when it flips.

There is a second ledger — not when the wave switches but which frequencies it contains:

s q ( t ) = sin t + sin 3 t 3 + sin 5 t 5 + sin 7 t 7 + , \mathrm{sq}(t) = \sin t + \frac{\sin 3t}{3} + \frac{\sin 5t}{5} + \frac{\sin 7t}{7} + \cdots,

its Fourier series. Only odd multiples of the fundamental frequency 11 appear, and the nnth harmonic arrives with amplitude 1/n1/n. The claim looks implausible — smooth waves summing to a jump? — and deserves to be watched happening. The figure plots the first three partial sums: S1=sintS_1 = \sin t, then S2S_2 adds 13sin3t\tfrac{1}{3}\sin 3t, then S3S_3 adds 15sin5t\tfrac{1}{5}\sin 5t.

Three blue waves of increasing darkness drawn over the same two periods: a dashed pale sine wave, a dashed medium curve whose crests have begun to flatten, and a solid dark curve with flatter tops, steeper crossings, and a small ripple. Toggling the curves' visibility shows each added odd harmonic pushing the shape closer to a square wave of height about 0.785.Explore in 3D (opens in a new tab)
The first three Fourier partial sums of the square wave of height π/40.785\pi/4 \approx 0.785, drawn over nearly two periods: the pale dashed S1=sintS_1 = \sin t, the medium dashed S2=S1+13sin3tS_2 = S_1 + \tfrac{1}{3}\sin 3t, and the solid dark S3=S2+15sin5tS_3 = S_2 + \tfrac{1}{5}\sin 5t, its tops flatter and its crossings steeper. Toggle each curve's visibility to replay the convergence one harmonic at a time.

Explore

  1. Observe. Hide S2S_2 and S3S_3. Alone, S1S_1 is a plain sine of height 11 — the right period and the right sign pattern already, but round-topped and, at its crest, taller than the plateau π/40.785\pi/4 \approx 0.785 it is aiming for.
  2. Predict. At the center of the plateau, t=π/2t = \pi/2, the next term contributes 13sin(3π/2)=13\tfrac{1}{3}\sin(3\pi/2) = -\tfrac{1}{3}. Will revealing S2S_2 raise or lower the middle of the crest? Decide, then toggle it on.
  3. Verify. Read the three center heights at t=π/2t = \pi/2: they are 11, then 1130.671 - \tfrac{1}{3} \approx 0.67, then 113+150.871 - \tfrac{1}{3} + \tfrac{1}{5} \approx 0.87 — the partial sums of the alternating series 113+151 - \tfrac{1}{3} + \tfrac{1}{5} - \cdots, whose limit is exactly π/4\pi/4. The plateau height is that famous series, straddled from above and below.
  4. Observe. Count the ripples riding the solid curve's plateau: three crests, at t=π/6t = \pi/6, π/2\pi/2, and 5π/65\pi/6. Each harmonic added contributes one more ripple and shrinks them all.
  5. Predict, then verify. The solid curve's tallest crests are the ones nearest the jumps — at t=π/6t = \pi/6 and 5π/65\pi/6, height 12+13+110=14150.93\tfrac{1}{2} + \tfrac{1}{3} + \tfrac{1}{10} = \tfrac{14}{15} \approx 0.93 — not the one at the center. Predict where the tallest crest of S4S_4 would sit, then check your reasoning against the pattern from S1S_1 to S3S_3. (That stubborn spike beside each jump is the Gibbs phenomenon: it narrows as terms are added but never shrinks below about 9%9\% of the jump.)

Connect

Why take the wave apart at all? Because for a linear equation, superposition turns the series into a term-by-term to-do list. Drive an undamped oscillator with the square wave,

x + ω 0 2 x = s q ( t ) , x'' + \omega_0^2\, x = \mathrm{sq}(t),

and each harmonic 1nsinnt\tfrac{1}{n}\sin nt produces its own steady response 1n(ω02n2)sinnt\frac{1}{n\,(\omega_0^2 - n^2)}\sin nt, exactly as in the beats section — provided ω0n\omega_0 \ne n. The denominators tell the story: the response is dominated by whichever harmonic sits closest to the natural frequency. And if ω0\omega_0 equals an odd integer, that single term resonates and grows without bound while every other term stays politely small.

This is the treacherous fact about periodic switching. A pure sinusoid resonates at exactly one frequency; a square wave carries the frequencies 1,3,5,7,1, 3, 5, 7, \ldots all at once and can resonate a system tuned to any of them. Matching the forcing period to the natural period is the resonance you expect. A square wave that switches three or five times slower than the system's natural oscillation excites a resonance you may not expect — the energy arrives through an overtone. Switched machinery must be designed against the whole ladder of frequencies, not a single rung.

An original work of XYZ Homework, built around interactive XYZ 3D figures, following the standard first-course sequence (first-order equations through systems and the phase plane). Distinct from the LibreTexts-sourced Differential Equations for Engineers (Lebl) edition, which has its own attribution. License: CC-BY-NC-SA-4.0.

These eBooks are a prerelease and are not yet certified conformant with WCAG 2.1 AA or ADA Title II. Every page is built against an automated accessibility gate, and the published editions will meet ADA Title II requirements when they release in late September 2026. If something is unusable, please tell us.