How to Find a Fourier Series: Coefficients, Symmetry and the Gibbs Overshoot
Compute Fourier coefficients by hand for a sawtooth wave, use odd and even symmetry to save work, check with Parseval and see why partial sums overshoot.

How to Find a Fourier Series: Coefficients, Symmetry and the Gibbs Overshoot
A Fourier series claims that almost any repeating shape can be built by adding sine and cosine waves of increasing frequency. A square wave, a sawtooth, the voltage from a rectifier: all of them are sums of pure tones. For a student the job is to find how much of each wave to use. Those amounts are the coefficients a_n and b_n. This guide shows how to compute them, how symmetry halves the work and how to sanity check the result.
The formulas on the interval from -pi to pi
For a function with period 2pi the series is
f(x) ≈ a_0/2 + sum over n of [a_n cos(nx) + b_n sin(nx)]
with
- a_n = (1/pi) times the integral from -pi to pi of f(x) cos(nx) dx
- b_n = (1/pi) times the integral from -pi to pi of f(x) sin(nx) dx
For a general period 2L, replace nx by n pi x/L and 1/pi by 1/L.
Let symmetry do half the job
If f is odd, meaning f(-x) = -f(x), every a_n is zero, because cosine is even and the product is odd, so it integrates to zero over a symmetric interval. Only sine terms survive. If f is even, every b_n vanishes and only cosines remain. Checking symmetry first can save a whole page of integration.
Worked example: the sawtooth f(x) = x
Take f(x) = x on (-pi, pi), repeated every 2pi. It is odd, so a_0 and all a_n are zero.
For b_n, the integrand x sin(nx) is even, so b_n = (2/pi) times the integral from 0 to pi of x sin(nx) dx. Integrate by parts with u = x and dv = sin(nx) dx:
the integral equals [-x cos(nx)/n] from 0 to pi plus (1/n) times the integral of cos(nx), and the second part is zero over 0 to pi.
The first part gives -pi cos(n pi)/n = -pi(-1)^n/n. Multiply by 2/pi:
b_n = 2(-1)^(n+1)/n
So b_1 = 2, b_2 = -1, b_3 = 2/3, b_4 = -1/2, and the series is
x ≈ 2 sin x - sin 2x + (2/3) sin 3x - (1/2) sin 4x + ...
Checking with Parseval's theorem
Parseval links the coefficients to the average of f^2. On this interval, (1/pi) times the integral of x^2 from -pi to pi equals 2pi^2/3, about 6.580. The sum of b_n^2 is 4(1 + 1/4 + 1/9 + ...) = 4·pi^2/6, which is the same 2pi^2/3. The match confirms the formula.
The theorem also tells you how good a partial sum is. The first three terms give 4 + 1 + 4/9 ≈ 5.444, about 83 % of the total. Adding the fourth term raises it to about 87 %. Slow growth like this is typical of functions with jumps.
The Gibbs overshoot
The periodic sawtooth jumps from pi to -pi at every odd multiple of pi. Near such a jump the partial sums overshoot the true value by roughly 9 % of the jump height, and adding more terms only squeezes the spike closer to the jump without shrinking it. Smooth functions without jumps, like a triangle wave, do not show this and their coefficients fall off much faster, like 1/n^2.
Frequent mistakes
- Forgetting the factor 1/2 on a_0 in the series, or dividing by 2 twice.
- Ignoring symmetry and wasting time computing coefficients that must be zero.
- Writing cos(n pi) as 1 instead of (-1)^n.
- Integrating over the wrong interval when the period is not 2pi.
- Expecting the series to equal f exactly at a jump. It converges to the midpoint, which is 0 for the sawtooth at x = pi.
Seeing it on screen
The Fourier Series Visualizer offers presets such as square, sawtooth and triangle waves, and lets you build your own function from pieces. Move the terms slider or press animate to watch the partial sum approach the target one harmonic at a time. The coefficient table and spectrum chart show which terms vanish by symmetry, the energy figure applies Parseval for you, and a statistic box measures the overshoot near a jump. Half-range sine and cosine series are available for problems on [0, L].
Limits
Coefficients are computed numerically, so tiny values appear as zero and the last digits may differ from exact fractions. Functions must be bounded and piecewise smooth, and the animation stops at 60 terms. This is a study aid for understanding series, not a signal-processing package, and it does not write the integration steps for you.


