Fourier series in this visualization
The top plot draws a function of period in ink and its partial sum in yellow: the constant term and every cosine and sine up to frequency . The strip below multiplies by one probe wave and shades the signed area between the product and the axis. The bottom strip lays out the coefficients found this way, cosines above and sines below.
Why does one area pick out one coefficient when holds all the waves at once? Over a full period, any two different waves from multiply to a product with zero area, while a sine or cosine times itself has area . Multiplying a sum of these waves by and integrating therefore removes every term except and leaves . In the two-sine highlight the strip splits the product in two, and the part with the other frequency cancels itself. The waves behave like perpendicular axes and each coefficient is the projection onto one of them, so adding a term never changes the coefficients already found.
With enough terms, the partial sums overshoot beside a jump. As grows, the peak narrows and moves toward the jump, but the overshoot does not vanish: for the square wave the excess tends to about 8.949% of the jump. Each is continuous, so it has to cross the jump over a short stretch, and on any interval containing the jump its largest error cannot shrink to 0. Continuity alone does not fix the size: the 8.949% comes from computing the partial sums, and every jump of a piecewise smooth function ends up with the same fraction.
Smoother functions need fewer terms. Here means the function repeated forever, so ends at that do not meet are a jump too. Integrating by parts moves the derivative from the wave onto and brings out a factor . Across a jump the first step leaves a boundary term with a factor : the square wave has for odd and 0 for even . If is continuous but its slope jumps, as at the triangle wave's corners, the first step goes through and the second leaves the term, so the coefficients shrink like . On the log scale, compare the bars with the dashed and lines.
The energy readout applies the same perpendicularity to squares. The integral of splits into the squares of the coefficients, with no cross terms:The readout gives the share of this total that already holds; the rest is its squared error, measured the same way. For the square wave holds about 81% and about 96%, while the overshoot is still there: a narrow peak adds little area. A partial sum can be close to on average and still miss it near a jump.
Things to notice
- The constant term is written so that the cosine formula also covers . The constant probe reads directly: the mean of .
- Odd functions such as the square wave have only sine terms and even ones such as only cosines, so one row of the spectrum stays empty.
Controls
- Click a bar in the spectrum to move the probe there.
- Choose Draw and drag across one period of the top plot. Your points are joined by straight segments and repeated on both sides.