Euler-Fourier formulas
/ OY-ler FOOR-ee-ay /
Once you believe a periodic signal is a sum of sines and cosines, the obvious next question is: how much of each? If a recipe is a stack of ingredients, the Euler-Fourier formulas are the measuring cups — they tell you the exact amount of every harmonic by a single integral. The trick that makes them work is a kind of sifting: each sine and cosine is 'invisible' to all the others when you integrate over a full period, so multiplying by one particular harmonic and integrating plucks out just that one coefficient.
For a function f of period 2L, the formulas are a_n = (1/L) integral over one period of f(x) cos(n pi x / L) dx for n = 0, 1, 2, ..., and b_n = (1/L) integral over one period of f(x) sin(n pi x / L) dx for n = 1, 2, .... You integrate over any interval of length 2L, often from -L to L. The reason a single n survives is orthogonality: integral of cos(m pi x / L) cos(n pi x / L) over a period is 0 unless m = n, and likewise for sines, while a sine times a cosine always integrates to 0. So when you multiply the whole series by cos(n pi x / L) and integrate, every term collapses to zero except the n-th, leaving L times a_n. The constant a_0/2 is then just the mean of f, the average height of the signal.
These formulas are the computational heart of the whole subject — every spectrum analyzer, every coefficient table, every separation-of-variables solution ends in an integral of exactly this form. They are also reassuringly local in spirit: to find one harmonic you never need to know the others, so you can compute as few coefficients as your accuracy demands. The honest caveat is that the formulas require f to be integrable over the period; for badly behaved f (non-integrable, or with the wrong period assumed) the integrals can fail to exist or give a misleading answer.
For f(x) = x on (-pi, pi) with period 2pi: by symmetry all a_n = 0, and b_n = (1/pi) integral from -pi to pi of x sin(n x) dx = -2 cos(n pi)/n = 2 (-1)^{n+1}/n, giving x = 2 [ sin x - sin 2x / 2 + sin 3x / 3 - ... ].
One integration by parts delivers every coefficient of the sawtooth at once — the formula does all the work.
Conventions differ: some books write the constant term as a_0 (not a_0/2) and divide by L (not 2L), so a stray factor of two is the single most common bug — always check which convention your formula for a_0 uses.