For the \(2\pi\)-periodic square wave that is \(1\) on \(0<x<\pi\) and \(-1\) on \(-\pi<x<0\), the Fourier series is \(\frac4\pi(\sin x+\frac{\sin3x}{3}+\frac{\sin5x}{5}+\cdots)\). Only odd sine harmonics appear for this particular symmetric waveform. Changing its offset, duty cycle or choice of origin can change the coefficients.
Symmetry removes some coefficients
This wave is odd, so its constant and cosine coefficients vanish. Its sine coefficient is \(b_n=\frac2\pi\int_0^\pi\sin(nx)\,dx=\frac{2}{n\pi}[1-(-1)^n]\). Even \(n\) gives zero, while odd \(n\) gives \(4/(n\pi)\). The result follows from the specified symmetry and interval. A shifted square wave can require a different combination of sine and cosine terms even when it represents a similar-looking signal.
Original calculation: build the value at π/2
At \(x=\pi/2\), the fundamental alone gives \(4/\pi\approx1.27324\). Adding the third harmonic gives \(\frac4\pi(1-1/3)\approx0.84883\). Adding the fifth gives about \(1.10347\), and adding the seventh gives about \(0.92158\). The finite sums alternately overshoot and undershoot the level \(1\) at this point. These values were calculated for this article; they are not measured audio amplitudes or a reproduction of an experiment.
What happens at a jump
Under the usual Fourier convergence conditions, the series approaches the function at continuity points and the average of the two one-sided limits at a jump. For this square wave, the left and right limits at zero are \(-1\) and \(1\), so the midpoint value is \(0\). Every sine term is also zero there. An ideal square wave can be defined with a chosen value at the isolated jump, but changing that single assigned value does not make the series converge to a different endpoint value.
Gibbs ringing does not vanish in height
Near a jump, higher partial sums develop a narrower oscillating region. The limiting overshoot is about \(8.95\%\) of the jump size, not \(8.95\%\) of whichever plateau you happen to use as a reference. Here the jump size is \(2\), so the overshoot is about \(0.179\) beyond the upper level, near the discontinuity. Increasing the number of terms squeezes the ringing closer to the jump without making its maximum relative height disappear. This is different from the values at a fixed point away from the jump, which do converge.
Choose a time scale when using a physical signal
To describe a signal with fundamental frequency \(f_0\), replace \(x\) by \(2\pi f_0t\). The included frequencies are then \(f_0,3f_0,5f_0,\ldots\). Any finite sum remains smooth and cannot reproduce an ideal instantaneous vertical transition exactly. Real devices also have bandwidth and amplitude limits. Before comparing a plotted sum with a recorded waveform, state the fundamental frequency, the number of harmonics, the normalization and any sampling assumptions. Otherwise a difference can come from the model or plotting method rather than a failure of Fourier analysis.
