Fourier Series Visualiser

A free Fourier series visualiser for square, triangle, sawtooth and half-wave rectified waves. Slide the number of terms from 1 to 50 and watch the partial sum converge, read the harmonic spectrum, and see the Gibbs overshoot appear.

What a Fourier series does

A Fourier series rewrites a periodic function as a sum of sines and cosines. This visualiser covers four classic waveforms — square, triangle, sawtooth and half-wave rectified — using the closed-form coefficients you will find in any textbook. Slide the number of terms up and down and you can watch the partial sum move towards the original wave on the graph. No numerical integration is involved, so the coefficients shown here are exact to within double-precision rounding.

The interesting part is how differently the four waveforms converge. The square and sawtooth waves have coefficients that decay as 1/n, so the ripple near the corners survives even when you add a lot of terms. The triangle wave decays as 1/n² instead, and around ten terms is already enough to sit almost exactly on top of the original. For the waveforms with a genuine jump, no number of terms removes the roughly 9% overshoot just before the discontinuity, and you can track that number directly in the peak-of-the-partial-sum readout.

How to use the Fourier series visualiser

  1. Pick a waveform Choose between the square, triangle, sawtooth and half-wave rectified waves. The series for that waveform and a note about how it converges appear right below the selector.
  2. Move the terms slider N runs from 1 to 50. The solid orange line is the partial sum and the dashed grey line is the original wave.
  3. Read the convergence figures The root mean square error and the largest error tell you numerically how much each extra term buys you. The peak of the partial sum measures the overshoot.
  4. Compare the table and the spectrum The bar chart and the table both show which harmonics carry how much amplitude. For the square wave you can see at a glance that every even harmonic is empty.

Tips for getting more out of it

  • Set the square wave to N = 5, then 15, then 45. The ripples get more numerous but barely shorter — that is the Gibbs phenomenon, and the overshoot stays at roughly 9% no matter how many terms you add.
  • Compare the triangle and square waves at the same N. The 1/n² versus 1/n decay shows up immediately: the error figures usually differ by an order of magnitude or more.
  • Only the half-wave rectified signal carries a constant term. If you have ever wondered why a rectifier output has a DC offset, the 1/π in its series is the answer.
  • If you need coefficients for a function of your own, use our Fourier coefficient calculator, which works out a₀, aₙ and bₙ by numerical integration.

Where the Fourier series visualiser helps

Following a lecture or a circuits textbook

A closed-form series on the page says nothing about how quickly it converges. Watching the wave build up term by term connects the shape of the formula to the shape of the result.

Working with harmonic distortion

That a square wave contains only odd harmonics while a sawtooth contains even ones too is a starting assumption in filter design and EMC work. The spectrum bar chart makes the difference obvious.

Learning about ringing in signal processing

Limiting the number of terms is exactly what limiting the bandwidth does, and the ripple you see near the corners is the same ringing you get from a sharp low-pass filter.

Explaining the timbre of an instrument

Two notes at the same fundamental frequency sound different when their harmonic content differs. Comparing the square and triangle spectra is the clearest example of that.

Fourier series terms explained

Fourier series
A representation of a periodic function as a sum of sines and cosines whose periods are the original period divided by a whole number. In principle the sum never ends.
Partial sum
The finite sum you get by cutting an infinite series off at the Nth term. The solid orange line on this page is a partial sum.
Fundamental
The n = 1 component, which has the same period as the original function. For a musical sound this is the component that sets the pitch.
Harmonic
A component whose frequency is a whole-number multiple of the fundamental. The nth harmonic sits at n times the fundamental frequency and shapes the timbre and the sharpness of the corners.
DC component
The zero-frequency component, equal to the average of the function over one period. It appears here as the constant term a₀/2.
Gibbs phenomenon
The overshoot a Fourier partial sum makes just before a jump discontinuity. Adding terms narrows the region affected but leaves the overshoot at roughly 9%.
Root mean square error
The square root of the mean squared difference between the original wave and the partial sum over one period. It is the usual single number for how well the approximation fits overall.

Frequently asked questions about Fourier series

For a function with a jump, the partial sum always overshoots just before the jump. This is the Gibbs phenomenon, and the size of the overshoot stays at about 9% no matter how many terms you use. What does shrink is the width of the region where it happens, which is why the root mean square error keeps falling steadily.

A square wave is half-wave symmetric: shift it by half a period and it flips sign. For any waveform with that symmetry all even-order coefficients are exactly zero, which is why the even bars in the spectrum are empty. A sawtooth wave lacks that symmetry, so its even harmonics do appear.

Yes. For these four waveforms the tool uses the closed-form textbook expressions directly, so the values are exact to within double-precision rounding rather than numerical approximations. Handling an arbitrary function needs numerical integration, which is why that lives in a separate tool.

Use our Fourier coefficient calculator, which computes the coefficients by numerical integration. Enter an expression, the period interval and the highest harmonic you want, and you get a₀, aₙ and bₙ as a table together with a plot of the reconstructed wave.
Tool-kun

Side Note — when mathematicians said a corner could not be built from smooth curves

Fourier series began with an idea Joseph Fourier brought to the problem of heat conduction in 1807. His contemporaries were not impressed: the claim that a function with corners could be written as a sum of perfectly smooth trigonometric terms struck Lagrange and others as plainly wrong, and Fourier faced serious opposition. As it turned out, they were not entirely mistaken — not every function has a series that converges at every point — and pinning down exactly which ones do became one of the driving questions of nineteenth-century analysis. Dirichlet's convergence conditions and the careful construction of the Riemann integral both grew out of it.

The Gibbs phenomenon is named after the physicist Josiah Willard Gibbs, although the English mathematician Henry Wilbraham described it first, back in 1848. Gibbs wrote about it in 1898, his account was the one that circulated, and the name stuck. The oddly specific figure of about 8.95% for the overshoot comes from the maximum of the sine integral function, and it is the same number at every jump discontinuity of every waveform.

That overshoot still turns up in everyday engineering. Cut the high frequencies out of digital audio and you get pre-echo, a faint sound arriving before the attack it belongs to; do the same to an image and you get ringing, the bands that hug a sharp edge. The smearing you see along block boundaries in a heavily compressed JPEG has the same root. Designing a filter with a carefully shaped window function is, among other things, a way of negotiating how much of that overshoot you are willing to accept — and moving the terms slider on this page lets you see exactly what is being traded away.