On this page
A square wave is about the least wavy signal there is: flat at +1, a sudden jump, then flat at −1. Yet you can build it entirely from smooth sine curves.
What is the Fourier series of a square wave?
Take the square wave with period 2π that equals +1 for 0 < x < π and −1 for −π < x < 0. Its Fourier series, as given in Wolfram MathWorld's square-wave entry, contains only sine terms with odd frequencies:
f(x) = (4/π)(sin x + sin 3x/3 + sin 5x/5 + sin 7x/7 + …)
The odd harmonic n has amplitude 4/(nπ), and every even harmonic is zero (MathWorld). So the bare sum sin x + sin 3x/3 + sin 5x/5 + … settles at π/4, about 0.785, on the flat top, not at 1.
How do you compute the coefficients by integration?
For a function of period 2π, the sine coefficient is b_n = (1/π) times the integral of f(x) sin nx over one period, with a matching a_n for the cosines (MathWorld).
Spot the symmetry. f is odd, f(−x) = −f(x), so f(x) cos nx is odd and every a_n, including the constant term, integrates to zero from −π to π.
Halve the work. f(x) sin nx is even, so b_n = (2/π) times the integral of sin nx from 0 to π.
Integrate. The integral of sin nx from 0 to π is [−cos nx / n] from 0 to π, which is (1 − cos nπ)/n.
Use cos nπ = (−1)^n. For even n this gives 1 − 1 = 0; for odd n it gives 1 + 1 = 2.
Assemble. b_n = 4/(nπ) for odd n and 0 for even n.
The antiderivative of sin nx is on the Class 12 integrals formula sheet. The biggest time-saver is step 1: over a full period the odd parts cancel, the same idea used for integrating a periodic function over many periods.
That series converges slowly; the Leibniz test for alternating series explains why it converges at all.
How do the partial sums build the square wave?
Call S_N the square-wave series stopped at sin Nx/N, times 4/π. At the middle of the flat top, x = π/2, the target is 1 (our arithmetic):
S_1 = 4/π ≈ 1.273: one sine hump, too tall in the middle and far too low near the edges.
S_3 = (4/π)(1 − 1/3) ≈ 0.849: the 3x term pulls the middle down and lifts the shoulders.
S_5 ≈ 1.103 and S_9 ≈ 1.063: the top flattens into a ripple that wobbles around 1.
Each new harmonic corrects part of the error, so the ripples get smaller and faster. On the flat top the series converges to 1. Exactly at a jump every sine is zero, so it gives 0: the midpoint of +1 and −1, the value MathWorld calls φ(c) (MathWorld).
Why is there an overshoot near the jump?
The derivative of S_N is a sum of cosines that first vanishes at x = π/(N + 1), so that is where the first peak sits. S_1 peaks at 1.273 at x = π/2, S_3 at about 1.200 at π/4, and S_9 at about 1.182 at π/10. The peak slides toward the jump, but it does not shrink to 1.
This is the Gibbs phenomenon, which Wolfram MathWorld defines as an overshoot, or "ringing", of Fourier series at simple discontinuities. Its size is fixed by the Wilbraham-Gibbs constant: as N grows, the peak beside a jump of size D tends to the midpoint plus (D/π) Si(π), where Si(π) = 1.851937… (MathWorld). For our wave D = 2, so the peak tends to (2/π)(1.8519) ≈ 1.179. That is an overshoot of 0.179, about 9% of the jump, however many terms you add.
Why two names? A 1979 history by Edwin Hewitt and Robert E. Hewitt, "The Gibbs-Wilbraham phenomenon", cites Henry Wilbraham's 1848 paper alongside J. Willard Gibbs's letters to Nature (doi:10.1007/BF00330404). Gibbs's letter "Fourier's Series" appeared in Nature on 27 April 1899 (doi:10.1038/059606a0).
How can you check this yourself?
Redo the five-step integral for the wave that is 1 on (0, π) and 0 on (π, 2π). You should get a constant 1/2 plus half of our series.
Plot S_1, S_3 and S_9 on a graphing calculator, find the first peak of each, and check that it lands at x = π/(N + 1).
If the integration steps trip you up, the Fermi Concept Library gives every concept in mathematics and physics its own lesson and its place in the map. When a picture helps more than algebra, the Fermi Simulation Lab has interactive simulations for the ideas that are easier to see than to read.



