From periodic functions to orthogonal bases

The trigonometric Fourier series decomposes a periodic function into an infinite sum of sinusoids. Beyond its practical value in signal processing, the theory connects naturally to linear algebra: the sine and cosine functions form an orthogonal basis in a Hilbert space, and computing Fourier coefficients is nothing more than projecting the function onto those basis vectors.

Deriving the coefficients

For a well-behaved 2L-periodic function f(x), we assume there exist coefficients aₙ and bₙ such that the Fourier series on the right converges to f(x). Since the n = 0 term reduces to a_0, the series is conventionally written with a standalone constant a₀/2 representing the function's average over one period.

Finding the coefficients proceeds in three steps, each exploiting the orthogonality of sinusoids over a symmetric interval:

  1. Integrate both sides between -L and L. All integrals inside the sum vanish (Appendix A), leaving a_0 — the function's mean value.
  2. Multiply by cos(mπx/L) for a positive integer m and integrate. Orthogonality (Appendix B) zeroes every term except aₘ, giving the cosine coefficients.
  3. Multiply by sin(mπx/L) and integrate. The same reasoning yields the sine coefficients.

The final coefficient formulas for f(x) are:

with integration carried out over one period. These assumptions — square integrability and piecewise smoothness — hold for virtually any function encountered in practice. Under these conditions the series converges pointwise: exactly at continuous points, and to the midpoint at jump discontinuities.

Simplifications and extensions

When f(x) is even above the midpoint, the product inside the integral is odd, making every bₙ zero. The result is a pure cosine series. For odd functions, the roles reverse: all aₙ coefficients (including a₀) vanish, leaving a sine series.

For a non-periodic function defined only on a finite interval, Fourier series still applies through periodic extension. Three natural choices exist: direct repetition (f(x + 2L) = f(x)), an even extension (mirroring the function symmetrically), or an odd extension (flipping the sign). Each produces a different series, yet all converge to the original function inside the interval. Even and odd extensions yield cosine and sine series respectively, which explains their practical appeal.

Aperiodic functions on the entire real line fall outside Fourier series territory entirely — that generalization is the Fourier transform.

Worked example: triangular wave

Consider the triangular function defined on [-2, 2] as n extended oddly and repeated with period 4. Since the function is odd, only sine coefficients are needed; aₙ vanishes for all terms.

With L = 2, the calculation exploits that the product of two odd functions (f and sine) is even, so integration over [-2, 2] doubles the integral over [0, 2]. Splitting the piecewise-defined function and using the integral identity from Appendix C yields, after simplification involving n, the coefficient:

The sine term becomes zero for integer multiples of π, leaving a series where all even terms vanish. The interactive chart demonstrates how partial sums with increasing n — set interactively on the page — converge to the triangular function; only the count of terms changes, since even coefficients contribute nothing.

Alternative representations

The sine-cosine form can be reorganized into a single phase-shifted sinusoid at each harmonic:

where the magnitude Aₙ and phase φₙ follow from Appendix D in terms of the original coefficients. This formulation is particularly useful in signal processing, where each term directly represents a harmonic's amplitude and phase in the frequency domain.

An equivalent complex-exponential representation also exists:

The derivation mirrors the trigonometric case: multiply by e^(-imπx/L) and integrate over one period — a general computation attributable to n in the exponential.

Appendix D: Phase-Shifted Sinusoids as Sine-Cosine Pairs

A general sinusoid with magnitude A, frequency ω, and phase φ can be written as:

w

This form has a well-known equivalence: it can be expressed as a weighted sum of a pure sine and a pure cosine, with no phase term. This relationship is closely tied to the behavior of summing sinusoids of identical frequency.

Starting from the trigonometric expansion of the phase-shifted term:

\theta

By defining C = A cos(φ) and D = -A sin(φ), the expression simplifies to:

\theta

The conversion between the two representations is reversible. To recover A and φ from C and D, square both definitions and sum them:

\theta

Dividing the two defining equations gives the phase:

w

Here, the atan2 function is used to respect the signs of both the numerator and denominator. Note that the phase φ is only defined up to additive multiples of .

Thus, for any A, ω, and φ, the phase-shifted sinusoid can always be rewritten in the equivalent sine-cosine form:

\theta

with the conversion formulas given above connecting the two parameter sets. This decomposition is particularly useful when working with linear systems, where sine and cosine components are handled independently.

[1]A function f(x) is called periodic if there exists some constant such that . In our case, we denote the period as to make presentation and calculations neater.

[2]Since , we know that it’s integrable on a finite interval

[3]There’s also an infinite number of less natural ways to extend the function; they will still work, but may make the calculation needlessly complicated

[4]I chose this one because the more common ones like a square wave and a sawtooth wave have many derivations available online, including on Wikipedia.

[5]Try it for yourself - it’s a good exercise.

[6]When for some n, the corresponding can be chosen arbitrarily.

[7]For a complex-valued f(x), this conjugate symmetry no longer holds in general. and may be complex, so and need not be conjugates.