Fourier Series Visualizer

Square, saw and triangle, built one harmonic at a time.

  • Epicycles draw shapes
  • Exact coefficients
  • Hear the harmonics
A brass drawing machine of linked rotating arms tracing a looping ink curve on paper under warm workshop light.

The guide

Every wave is a stack of circles, and the corners are where the stack never quite settles

Fourier built heat flow out of sums of sines over his critics' objections. The ripple that survives at every jump shows where both sides had a point.

  • 21 December 1807 Fourier's heat memoir is read to the Paris Institute
  • 4/(pi n) square wave coefficient, odd harmonics only
  • 8.95 percent limit of the overshoot, as a share of the jump
  • 1848 Wilbraham's paper on the overshoot, half a century early
Read the full guide Fold the guide 7 min · 13 sources

On 21 December 1807 a memoir on the propagation of heat in solid bodies was read to the Paris Institute. Its author, Joseph Fourier, had worked on the problem for about three years while serving as a prefect in Grenoble. The memoir solved the equation of heat flow with infinite series of trigonometric functions. The way it expanded functions into those series did not sit well with the best mathematicians in the room.

A committee of Lagrange, Laplace, Monge and Lacroix was set up to report on the work, and in 1808 Lagrange and Laplace objected to exactly that: the expansion of functions as trigonometrical series, what we now call Fourier series. Fourier answered. They were not convinced. Biot, and later Poisson, raised a second objection about how the heat equations had been derived. When the Institute made heat conduction the subject of its 1811 prize, Fourier entered and won, yet the report said his analysis left something to be desired in generality and even rigour. The prize essay was published in 1822 as Analytical Theory of Heat.

Two centuries on, the objection and the method both look partly right. That tension is the most useful thing to understand about a Fourier series, and you can watch it happen.

Harmonics, and why a square wave wants only odd ones

A periodic wave repeats every period. A harmonic is a sine or cosine that repeats a whole number of times in that same period: once for the first harmonic, twice for the second, and so on. The Fourier series of a wave writes it as its average value plus a weighted sum of these harmonics. Each weight, called a coefficient, is found by multiplying the wave by one harmonic and averaging over a period.

The standard reference from the US National Institute of Standards and Technology gives the coefficients as exactly those averages, with the cosine weights written a_n and the sine weights b_n. It notes two shortcuts. If the wave is symmetric about time zero, every sine weight is zero; if it is antisymmetric, every cosine weight is zero. Symmetry decides, before any arithmetic, which harmonics can appear at all.

Take a square wave that sits at plus one for half a period and minus one for the other half. It is antisymmetric, so only sines survive. It has a second symmetry too: shift it by half a period and it turns upside down. Every even harmonic repeats a whole number of times in half a period, so it cannot follow that flip and must cancel when averaged. Only the odd harmonics remain, and each has weight 4/(pi n). The first harmonic carries 4/pi, about 1.27, the third a third of that, the fifth a fifth.

That 1.27 is worth a pause. The first sine is taller than the square wave it is trying to build. The smaller harmonics then pull its crest down and steepen its sides. Add the third harmonic and, a quarter of the way into the period, the sum drops from 1.2732 to 0.8488. Keep going and the flat tops start to appear, with a ripple riding on them.

The rate at which the weights shrink says something about the shape. The same reference states that if the m-th derivative of a wave is piecewise continuous, its coefficients fall faster than 1/n to the power m. The closed forms show the pattern plainly. A square wave has a jump, and its weights fall only as 1/n. A triangle wave has corners but no jump, and its weights fall as 1/n squared. On a plot with both axes logarithmic, those are straight lines of different slope. The steeper the line, the fewer terms you need before the picture looks right.

The overshoot that never goes away

Here is where Lagrange’s doubt earns its keep. At a jump, the series cannot pick a side. It converges to the midpoint of the jump, as the reference states, and the convergence is not uniform there. The sum overshoots.

The overshoot does not shrink as you add terms. It gets narrower and moves closer to the jump, but its height settles at a fixed share of the jump. The reference works through the series of odd sines, shows that the first peak equals about 1.1789 times the target level, and says the sum overshoots its target by approximately 18 percent. The target sits half a jump above the middle, so that is about 9 percent of the whole jump. Exactly, the share is the sine integral evaluated at pi, divided by pi, minus one half. The sine integral at pi is 1.851937052 to nine places, so the limit is 0.0895 of the jump, or about 8.95 percent.

That number is sometimes called the Wilbraham-Gibbs constant, after the English mathematician Henry Wilbraham and the American scientist J. Willard Gibbs of New Haven. The order of the names matters. Wilbraham analysed the effect in a paper of 1848, On a certain periodic function, which drew little attention for decades. The phenomenon became famous half a century later, after an exchange in the journal Nature about how the series of a square wave converges. Gibbs wrote a note on it in 1898 and a letter titled Fourier’s Series in 1899. A historical study of 1979 by Edwin Hewitt and Robert Hewitt carries the double name in its title.

The worked example is easy to reproduce. Choose the square wave and set the number of harmonics to 10: the measured overshoot is 9.12 percent of the jump. At 100 harmonics it is 8.95 percent. At 1,000 it is 8.949 percent, within a thousandth of a percentage point of the limit. Ten harmonics already carry 95.96 percent of the wave’s energy, yet the ripple at the edge stays the same height no matter how many you add.

Energy is the other half of the story, and it is where Fourier wins. The average of the squared wave equals the sum of the squared coefficients, with the right factors of one half. This is Parseval’s identity, and the reference states it as an equality for any square integrable function. So the missing energy, the error measured as a root mean square, really does go to zero. The series converges in the average sense even while it refuses to converge uniformly at the jump. Both statements are true at once.

The overshoot can be tamed, at a price. Averaging the successive partial sums, the method associated with Fejer, uses a kernel that is never negative, and that removes the overshoot. Sigma approximation, which weakens the higher harmonics, shrinks it a great deal. Both soften the jump itself, trading a sharp edge for a quiet one. In the tool, the sigma version leaves about 1.19 percent and the Fejer version none.

From Ptolemy’s circles to drawing machines

Long before anyone wrote down a sine series, astronomers were adding circles. In the Almagest, Ptolemy predicted the positions of the sun, moon and planets with combinations of circular motion known as epicycles. The tidal history published by the US National Oceanic and Atmospheric Administration reports the tradition that Eudoxus, as early as 356 BC, explained the irregular motions of the planets by combinations of uniform circular motions.

A Fourier series in complex form is exactly such a combination. Each term is a vector of fixed length spinning at a whole number of turns per period. Put them end to end and the tip draws the wave. Allow negative turning speeds as well and the tip can draw any closed curve in the plane, including one you sketch with a finger. With as many circles as sample points, the curve passes through every sample exactly; with fewer, you get the best smooth shape those circles can make. A smooth outline needs few circles. A sharp corner needs many, for the same reason a square wave does.

Machines built on this idea did real work. The NOAA history says William Thomson, later Lord Kelvin, devised the harmonic analysis of tides around 1867. Tide tables for US ports were computed on the Ferrel tide predicting machine from 1885 to 1911 and on the Coast and Geodetic Survey Tide Predicting Machine No. 2 from 1912 to 1965. Digital computers replaced them in 1966. The principle behind them, in the NOAA account, is that any periodic motion can be resolved into a sum of simple harmonic motions. Analysis runs that principle backwards, taking a measured curve apart into its harmonics; in 1898 A. A. Michelson and S. W. Stratton published a paper titled A new harmonic analyzer.

Where the series lives now, and how to read a spectrum

The same arithmetic sits inside ordinary files. The Library of Congress format description for JPEG notes that its lossy modes apply discrete cosine transforms to blocks of 8 by 8 pixels. Sound synthesis meets the overshoot and its cousin, aliasing. The W3C Web Audio specification warns that frequencies above half the sample rate fold back into lower frequencies unless they are removed first. A square wave with every harmonic would fold. Building it only from harmonics below that limit keeps it clean.

Reading a spectrum is reading the recipe. Each bar is one harmonic. Its height is that harmonic’s share of the wave, and its phase says where in the period it peaks. Gaps tell you about symmetry: no even bars means the wave flips when shifted by half a period. The slope of the bar tops, on log axes, tells you whether the wave jumps, bends sharply or curves smoothly.

There are limits worth stating plainly. A series describes a periodic wave, so a single event that never repeats is outside its reach unless you pretend it does. A sampled wave can only hold harmonics up to half its sample count. And a truncated series near a jump is always wrong by about nine percent of that jump, however many terms you spend. Smoothing hides the ripple by blurring the edge, which is a choice, not a cure.

Fourier’s critics were right that his expansions needed care. Fourier was right that the idea was worth the care. The ripple at the corner is the meeting point of both, and it has kept its height for more than two hundred years.

Sources

Every source consulted for this guide. Links checked October 17, 2026.

  1. Joseph Fourier (1768 - 1830) - Biography MacTutor History of Mathematics, University of St Andrews
  2. 1.8 Fourier Series NIST Digital Library of Mathematical Functions
  3. 6.16 Mathematical Applications NIST Digital Library of Mathematical Functions
  4. A036792: Decimal expansion of Integral_{x=0..Pi} (sin(x)/x) dx The On-Line Encyclopedia of Integer Sequences
  5. Fourier's Series (Nature, 1899) OpenAlex record of J. W. Gibbs's letter
  6. The Gibbs-Wilbraham phenomenon: An episode in fourier analysis OpenAlex record, Archive for History of Exact Sciences
  7. Gibbs phenomenon Wikipedia
  8. J Willard Gibbs (1839 - 1903) - Biography MacTutor History of Mathematics, University of St Andrews
  9. Ptolemy (85 - 165) - Biography MacTutor History of Mathematics, University of St Andrews
  10. History of Tidal Analysis and Prediction NOAA Tides and Currents
  11. A new harmonic analyzer OpenAlex record, American Journal of Science
  12. JPEG Image Encoding Family Library of Congress, Sustainability of Digital Formats
  13. Web Audio API 1.1 World Wide Web Consortium