Sine and Cosine Series
A shortcut hiding in symmetry
A general Fourier series needs both families of terms — cosines to capture the
"mirror-like" part of a wave and sines to capture the "spinning" part — and finding each
coefficient means grinding through an integral from -L to
L. That's real work, term after term. But sometimes half of it
evaporates before you pick up a pencil, just by looking at the shape of the function.
Two special symmetries show up constantly in practice:
-
Even functions are mirror images across the vertical axis:
f(-x) = f(x). A parabola x^2 is the classic
shape — the left half is a perfect reflection of the right half.
-
Odd functions look unchanged after being spun 180^\circ
through the origin: f(-x) = -f(x). A plain diagonal line through the
middle, like x^3, is the classic shape.
Spot which one a periodic function has, and an entire family of Fourier coefficients is
guaranteed to vanish — no integration required to know it.
Why symmetry kills half the coefficients
Recall the full series on [-L, L]:
f(x) = \frac{a_0}{2} + \sum_{n=1}^{\infty}\Big(a_n\cos\frac{n\pi x}{L} + b_n\sin\frac{n\pi x}{L}\Big),
with a_n = \frac{1}{L}\int_{-L}^{L} f(x)\cos\frac{n\pi x}{L}\,dx and
b_n = \frac{1}{L}\int_{-L}^{L} f(x)\sin\frac{n\pi x}{L}\,dx.
-
If f is even, every
b_n = 0 — the series is cosine-only (plus the
constant term).
-
If f is odd, a_0 and
every a_n = 0 — the series is sine-only.
The reason is a small piece of algebra about symmetry itself. \cos is
an even function and \sin is an odd function, and multiplying
symmetries combines the way signs combine: even×even = even, odd×odd = even, but
even×odd = odd. Now use the one fact that does all the work: the integral
of an odd function over a symmetric interval
[-a, a] is always exactly zero — whatever area piles up on the
positive side is cancelled exactly by the negative side. An even function gets no
such free cancellation; its integral is generally not zero.
So if f is even, the integrand
f(x)\sin\frac{n\pi x}{L} is even×odd = odd, and its integral
(that's b_n) must be zero — for every n,
without computing a single one. If f is odd, the integrand
f(x)\cos\frac{n\pi x}{L} is odd×even = odd, so
a_n = 0 every time, including a_0.
Long before calculators, anyone analysing a vibration, a sound wave, or an electrical signal by
hand had every incentive to spot symmetry first — it could cut an afternoon of integration in
half. That habit never went away. Recognising a signal's symmetry before touching an integral (or
a computer routine) is still a genuine time-saver today, because it tells you in advance exactly
which coefficients are worth computing at all.
Many real signals aren't just accidentally symmetric — they're symmetric by design. A
plain alternating current is built to be an odd function of time: equal pushes forward and
backward around zero, with no lopsided "bias." That built-in oddness guarantees the signal's
average is exactly zero and its Fourier series is sine-only, which is exactly what a power
engineer wants and expects to see.
Worked example: even, odd, or neither?
The test is always the same: compute f(-x) and compare it with
f(x) and -f(x).
1. f(x) = x^2. Then
f(-x) = (-x)^2 = x^2 = f(x). That matches
f(x) exactly, so f is even —
its Fourier series (on any symmetric interval) needs cosine terms only.
2. f(x) = x^3 - x. Then
f(-x) = (-x)^3 - (-x) = -x^3 + x = -(x^3 - x) = -f(x). That matches
-f(x) exactly, so f is odd —
sine terms only.
3. f(x) = x^2 + x. Then
f(-x) = x^2 - x. Compare: this is neither
f(x) = x^2 + x nor -f(x) = -x^2 - x. So
f is neither even nor odd — no shortcut, both families
of coefficients are needed.
Worked example: a sawtooth that is odd for free
Take f(x) = x on (-\pi, \pi), repeated with
period 2\pi — a rising "sawtooth" ramp that snaps back down at each
\pm\pi. Check the symmetry first:
f(-x) = -x = -f(x). It's odd. That single check tells us, before any
integration, that a_0 = 0 and every a_n = 0 —
the whole cosine family is dead on arrival.
Only the sine coefficients survive, and they're a standard integration-by-parts computation:
b_n = \frac{1}{\pi}\int_{-\pi}^{\pi} x\sin nx\,dx = \frac{2}{\pi}\int_0^\pi x\sin nx\,dx = \frac{2(-1)^{n+1}}{n},
so the finished series is
f(x) = \sum_{n=1}^{\infty}\frac{2(-1)^{n+1}}{n}\sin nx = 2\Big(\sin x - \frac{\sin 2x}{2} + \frac{\sin 3x}{3} - \cdots\Big).
Check it genuinely vanished: try computing a_1 the long
way, \frac{1}{\pi}\int_{-\pi}^{\pi} x\cos x\,dx. The integrand
x\cos x is odd (odd × even), so on the symmetric interval
(-\pi, \pi) the positive-side area and the negative-side area cancel
exactly, and the integral really is zero — matching what the symmetry argument promised without
any calculation at all.
This is, in fact, the very same series that turns up when f(x)=x on
[0,\pi] is deliberately extended to be odd (below) — except
here nothing had to be manufactured. The function already was odd on its own natural domain, so the
vanishing happened automatically.
It's tempting to hunt for symmetry everywhere, but most ordinary functions are neither
even nor odd. Try f(x) = e^x: then
f(-x) = e^{-x}, which is not equal to e^x nor
to -e^x. No shortcut exists here — you need the full series,
with both a_n and b_n computed the honest
way.
Don't force a symmetry that isn't there. A common mistake is shifting a function by a constant —
f(x) = x + 1 looks almost like the odd sawtooth above, but
f(-x) = -x+1 is neither f(x) nor
-f(x). That lone +1 is enough to break the
symmetry completely and bring every cosine coefficient back to life.
Later, the whole series gets rewritten using complex exponentials instead of separate sines and
cosines — see the
complex Fourier series.
Even there, evenness and oddness leave a fingerprint: an even function ends up with real
coefficients, an odd function with purely imaginary ones. The shortcut never really disappears —
it just changes costume.
Boundary-value problems usually live on a one-sided interval like
[0, L] — the length of a rod, a string fixed at both ends. There we
get to choose how to extend f to the full
[-L, L] before expanding it, and the choice decides whether we get a
pure sine series or a pure cosine series. These are the half-range expansions —
the same even/odd trick above, but now deliberately engineered rather than found ready-made.
-
Extend f to be odd → a
sine series, f(x) = \sum b_n\sin\frac{n\pi x}{L}
with b_n = \frac{2}{L}\int_0^L f(x)\sin\frac{n\pi x}{L}\,dx.
-
Extend f to be even → a
cosine series, f(x) = \frac{a_0}{2} + \sum a_n\cos\frac{n\pi x}{L}
with a_n = \frac{2}{L}\int_0^L f(x)\cos\frac{n\pi x}{L}\,dx.
Why the choice matters for boundaries
The sine series vanishes at x = 0 and
x = L — every term \sin\frac{n\pi x}{L} is
zero there. That makes it the natural fit for Dirichlet conditions where the
ends are pinned to zero (a rod held at 0^\circ, a string clamped at
both ends). The cosine series instead has zero slope at the ends, matching
Neumann conditions (an insulated end, no heat flow). So the physics of the
boundary picks the expansion for you — a fact the PDE course uses constantly.
Same function, two series
Take f(x) = x on [0, \pi]. The odd extension
gives the sine series \sum \frac{2(-1)^{n+1}}{n}\sin nx; the even
extension gives the cosine series
\frac{\pi}{2} - \frac{4}{\pi}\sum_{k\ \text{odd}}\frac{\cos kx}{k^2}.
Both reproduce f on [0, \pi] — switch
between them and slide N. (Notice the cosine series, with its
1/k^2 decay, converges noticeably faster.)
See it explained