Separation of Variables
From bio-physics-wiki
Separation of Variables is the most common approach to solve linear PDEs. The idea is that the solution is a product of functions that depend on one variable only \begin{align} u(x,t)=v(t)\cdot w(x) \end{align} To introduce the method we solve the wave equation by separation of variables \begin{align} u_{tt}=c^2u_{xx} \end{align} If we plug in the product we get \begin{align} v''(t)w(x)=c^2v(t)w''(x) \end{align} separating variables we have \begin{align} \frac{v''(t)}{v(t)}=c^2 \frac{w''(x)}{w(x)} \end{align} Now comes the key idea that allows us to solve the equation. The left side of the equation is a function of $t$ only, and the right side of the equation depends only on $x$. The only way this is possible is when both are constant \begin{align} \frac{v''(t)}{c^2 \, v(t)}= \frac{w''(x)}{w(x)}=\lambda \end{align} Lambda can be zero, positive or negative
Case $\lambda =0$ \begin{align} v''(t)&=0 \Rightarrow v(t)=A+Bt \\ w''(t)&=0 \Rightarrow w(x)=C+Dx \end{align} Case $\lambda = \beta^2 > 0$ \begin{align} v''(t)&=\beta^2c^2 v(t) \Rightarrow v(t)=Ae^{\beta c t} + Be^{-\beta c t} \\ w''(x)&=\beta^2 \Rightarrow w(x)=v(t)=Ce^{\beta x} + De^{-\beta x} \end{align} Case $\lambda = -\beta^2 < 0$ \begin{align} v''(t)&=-\beta^2c^2 v(t) \Rightarrow v(t)=A sin(\beta c t) +B cos(\beta c t) \\ w''(x)&=-\beta^2 \Rightarrow w(x)=C sin (\beta x ) +D cos (\beta x) \end{align}
For PDE problems with so called Dirichlet boundary conditions we have
\begin{align} u(0,t)=u(L,t)=0 \end{align}
For $\lambda$ smaller than one and Dirichlet boundery conditions the solution becomes \begin{align} w(0)=C \, sin (\beta 0 ) + D \, cos (\beta 0)=D=0\\ C \, sin (\beta L ) =0\\ \tag{1} \end{align} We are not interested in the trivial case $C=0$ so the argument of the $sin()$ must be a multiple of $\pi$ to satisfy equation (1) \begin{align} \beta L &= n \pi \hspace{1cm} \text{for }(n=1,2,3, \dots) \\ \lambda_n &=\beta_n^2= \left( \frac{ n \pi }{L} \right)^2 \\ \end{align} So there are an infinite number of solutions to this problem, one for each $n$. They are \begin{align} u_n(x,t)=w_n(x) \cdot v_n(t)=\left( A_n \, cos \frac{n \pi ct}{L} + B_n \, sin \frac{n \pi ct}{L} \right) \, sin \frac{n \pi x}{L} \end{align} Since the wave equation is linear, a sum of solutions is again a solution for any finite sum
\begin{align} u(x,t)=\sum_n \left( A_n \, cos \frac{n \pi ct}{L} + B_n \, sin \frac{n \pi ct}{L} \right) \, sin \frac{n \pi x}{L} \tag{2} \end{align}
With the notion of Fourier Series this result can satisfy arbitrary initial conditions
\begin{align} u(x,0)=\phi(x) \hspace{1cm} u_t(x,0)=\psi(x)\\ \end{align}
The derivative of $u(x,t)$ with respect to time is \begin{align} u_t(x,t)=\sum_n \left(\frac{n \pi c}{L} \, A_n \, -sin \frac{n \pi ct}{L} +\frac{n \pi c}{L} \, B_n \, cos \frac{n \pi ct}{L} \right) \, sin \frac{n \pi x}{L}\end{align} so we get at $t=0$ \begin{align} u_t(x,0)=\sum_n \frac{n \pi c}{L} \, B_n \, sin \frac{n \pi x}{L} \end{align} and we can develop the initial conditions $\phi,\psi$ into a Fourier Series.
\begin{align} \phi(x) &= \sum_n A_n \, sin\frac{n \pi x}{L}\\ \psi(x) &= \sum_n \frac{n \pi c}{L} \, B_n \, sin \frac{n \pi x}{L} \end{align}
The solution (2) is thus quiet general.