Motivation
Consider the following boundary value problem:
\[u_t = k u_{xx}, \quad u(0,t) = u(l,t) = 0,\]Separate the variables by taking \(u(x,t) = X(x) T(t)\), this becomes
\[T'(t)/kT(t) = X''(x)/X(x)\]along with \(X(0) = X(l) = 0\). Since the LHS depends solely on \(t\) and the RHS on \(x\), both must be equal to a constant, \(A\):
\[T'(t) = AkT(t), X''(x) = AX(x).\]The general solution for the equation for \(T\) is
\[T(t) = C_0 e^{Akt}\], while for \(X\) is
\[X(x) = C_1 \cos\lambda x + C_2 \sin \lambda x\]where \(\lambda = - \sqrt{-A}\). The boundary condition \(X(0) = 0\) forces \(C_1 = 0\), hence \(C_2 \sin\lambda l =0\). For nontrivial solutions, \(\lambda l = n\pi\) for some \(n\in \mathbb{Z}\), in other words \(A = -(n\pi/l)^2\). We take \(n>0\) since \(n=0\) gives zero solution and \(n\mapsto -n\) amounts to \(C_2 \mapsto -C_2\). Hence, taking \(C_0 = C_2 = 1\), for every \(n\in\mathbb{N}^+\) we have a solution \(u_n(x,t)\) for the boundary value problem, namely,
\[u_n(x,t) = \exp\left(\frac{-n^2\pi^2 k t}{l^2}\right)\sin\frac{n\pi x}{l}.\]Linear combinations of the \(u_n\)'s are also solutions. Hence we can take an infinite linear combination \(u = \sum a_n u_n\). Does it converge?
Now with an initial condition \(u(x,0) = f(x)\), provided that \(f(x) = \sum a_n \sin\frac{n\pi x}{l}\), the solution \(u\) shall do the job. The problem now becomes the determination of \(a_n\). Now the problem becomes: how to expand \(f(x)\) in terms of \(\sin\frac{n\pi x}{l}\)? Can it be done?
If the boundary condition is not Dirichlet but Neumann, i.e., \(u_x(0,t) = u_x(l,t) = 0\), then the solution \(u\) becomes the previous \(u\) with \(\sin\) replaced by \(\cos\) The problem becomes how to expand \(f(x)\) in terms of \(\cos\frac{n\pi x}{l}\). Can it be done?
To simplify the issue, we note that \(f\) is a function on an interval \((0,l)\). A function on an interval \((0,l)\) is a periodic function with period \(l\) restricted to \((0,l)\) (with some subtleties on $nl$'s; which we for the moment ignore), thus we can without loss of generality study periodic functions \(f(\theta + 2\pi) = f(\theta)\). The expansion we want can be written as
\[f(\theta) = \frac{1}{2}a_0 + \sum (a_n \cos n\theta + b_n \sin n\theta),\]or even better,
\[f(\theta) = \sum c_n e^{in\theta}\], but this time with \(n\in\mathbb{Z}\).