The Fourier Coefficients

We want to write a function as a sum of sines and cosines. The orthogonality of those building blocks hands us each coefficient almost for free — by exactly the same projection that recovers a vector's components.

For a vector, the component along a unit axis \mathbf{e}_k is the dot product \mathbf{v}\cdot\mathbf{e}_k. For a function we project the same way: to find the amount of \sin\frac{n\pi x}{L} inside f, take the inner product of f with that mode and divide by the mode's own "length squared".

Deriving one coefficient

Suppose f(x) = \sum_k b_k \sin\frac{k\pi x}{L}. Take the inner product of both sides with a single mode \sin\frac{n\pi x}{L}:

\int_{-L}^{L} f(x)\sin\frac{n\pi x}{L}\,dx = \sum_k b_k \int_{-L}^{L}\sin\frac{k\pi x}{L}\sin\frac{n\pi x}{L}\,dx.

Orthogonality kills every term in the sum except k = n, where the integral equals L. The entire infinite sum collapses to one term:

\int_{-L}^{L} f(x)\sin\frac{n\pi x}{L}\,dx = b_n\,L \;\Longrightarrow\; b_n = \frac{1}{L}\int_{-L}^{L} f(x)\sin\frac{n\pi x}{L}\,dx.

That is the whole idea: orthogonality turns "solve for infinitely many unknowns at once" into "read off each one with a single integral".

For a function f on [-L, L], the coefficients are

Each b_n is the projection of f onto the nth sine — how much of that ripple is "inside" f.

One mode at a time

Take f(x) = x on [-\pi, \pi]. Its sine coefficients work out to b_n = \dfrac{2(-1)^{n+1}}{n} — so the low modes carry most of the weight and the contributions taper off. The faint line is f; the bold curve is the single projected mode b_n\sin(nx). Step n to watch each ripple's amplitude — exactly what the integral above measures.