Sine and Cosine Series

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.

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.)