Wize Differential Equations Textbook > Fourier Series

Fourier Series of Square and Triangular Waveforms

Square and Triangular Waves: Symmetry, Coefficients, and What the Harmonics Mean

1. The series and the three symmetry shortcuts

A function of period 2L is written as a constant plus cosine and sine harmonics: f(x) = a0/2 + Σn≥1 [ an cos(nπx/L) + bn sin(nπx/L) ], with an = (1/L)∫ f(x) cos(nπx/L) dx and bn = (1/L)∫ f(x) sin(nπx/L) dx taken over any full period.


Three symmetry tests remove coefficients before you integrate anything.


  • Even symmetry, f(−x) = f(x): every bn vanishes, because an even function times an odd sine is odd and integrates to zero over a symmetric interval. Only cosines and the constant survive.
  • Odd symmetry, f(−x) = −f(x): every an vanishes, including a0. Only sines survive.
  • Half-wave symmetry, f(x + L) = −f(x): every even-numbered harmonic vanishes, whichever family it belongs to. Only n = 1, 3, 5, … survive.


These tests are independent, so a waveform can satisfy two of them at once and lose two families of coefficients. Note that a zero mean is a weaker statement than odd symmetry: a zero mean forces only a0 = 0, while odd symmetry forces an = 0 for every n.

2. The square wave

Take s(x) = +1 on (0, π) and s(x) = −1 on (−π, 0), repeated with period 2π, and assign value 0 at the jump points, so L = π. It is odd, so all an = 0, and it satisfies s(x + π) = −s(x), so only odd harmonics survive. One integral finishes the job:


bn = (2/π) ∫0π sin(nx) dx = (2/π) · [1 − cos(nπ)]/n = 2[1 − (−1)n]/(nπ).


That is 4/(nπ) for odd n and 0 for even n, exactly as the half-wave test predicted. So s(x) = (4/π)[ sin x + sin 3x/3 + sin 5x/5 + … ].


The leading coefficient is 4/π ≈ 1.27, which overshoots the wave's own height of 1, a sine of amplitude 1 would be too small, and the higher harmonics subtract near the peak to flatten the top.

3. The triangular wave

Take t(x) = |x| on (−π, π), repeated with period 2π. It is even, so all bn = 0. The mean is not zero, so the constant term survives: a0 = (2/π)∫0π x dx = π, giving a constant a0/2 = π/2, which is just the average height. Integration by parts gives


an = (2/π) ∫0π x cos(nx) dx = (2/π) · [cos(nπ) − 1]/n2,


which is −4/(πn2) for odd n and 0 for even n. So t(x) = π/2 − (4/π)[ cos x + cos 3x/9 + cos 5x/25 + … ].

4. Why the decay rates differ, and what partial sums look like

Compare the two results: for these piecewise-smooth periodic waveforms, the asymptotic envelope of the square wave's potentially nonzero coefficients is of order 1/n, while the triangle's is of order 1/n2.


More generally in this class, a jump discontinuity in the function produces a nonzero-coefficient envelope of order 1/n; continuity together with a piecewise-smooth derivative having jumps produces an envelope of order 1/n2.


These are envelope rates: symmetry or cancellation can make selected harmonics exactly zero. Additional regularity can yield faster envelopes when the corresponding hypotheses hold. Scaling the amplitude multiplies every coefficient by the same constant and does not change the envelope exponent.


The practical consequence is visible in partial sums. Because the triangle's fifth harmonic already carries only 1/25 of the fundamental's weight, for t(x) = |x|, the constant term plus the first three nonzero cosine terms (n = 1, 3, 5) have maximum absolute error about 0.105 everywhere, roughly 3.35% of the wave's peak value π.


The square wave's fifth harmonic still carries 1/5 of the fundamental, so many more terms are needed.


As more odd harmonics are retained, the maximum overshoot near a jump approaches about 9% of the jump, while the ripple narrows. The chart shows the first two nonzero partial sums against the square wave they are approximating.

Square wave (assigned 0 at jumps) and its first two nonzero partial sums over one period

Square wave (assigned 0 at jumps) and its first two nonzero partial sums over one period

5. Reading the spectrum

The coefficients are a physical description, not just bookkeeping. A sinusoidal component of amplitude A contributes A2/2 to the mean square of the signal, so the squared coefficients tell you how the signal's power is distributed across frequency.


Because the square wave's coefficients decay slowly, an appreciable share of its power sits above the fundamental, which is why passing a square wave through a low-pass filter visibly rounds its edges.


A triangular wave of the same period loses far less when the same filter is applied, because its power is concentrated in the first harmonic.

Let s(x) be the square wave of period 2π defined by s(x) = +1 for 0 < x < π and s(x) = −1 for −π < x < 0.

Which statement correctly identifies the surviving Fourier coefficients and gives the correct reason?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

For the square wave of period 2π the nonzero coefficients are bn = 4/(nπ) with n odd. For the triangular wave t(x) = |x| on (−π, π), also of period 2π, the nonzero coefficients are an = −4/(πn2) with n odd, plus a constant term.

Which statement best explains why the triangular wave's coefficients fall off faster with n?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Mark Yourself Question

  1. Grab a piece of paper and try this problem yourself.
  2. When you're done, check the "I have answered this question" box below.
  3. View the solution and report whether you got it right or wrong.

Let g(x) be the square wave of period 4 defined by g(x) = 2 for 0 < x < 2 and g(x) = −2 for −2 < x < 0.

(a) State which coefficient families vanish and why. (b) Derive a general formula for the surviving coefficients. (c) Evaluate the coefficients of the third and fourth harmonics.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors