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