One of the methods to solve a partial differential equation is to use separation of variables.
For example, consider the heat equation:
$$
u_t - a^2 u_{xx} = 0, \qquad 0 < x < L,\ 0 < t,
$$
with the boundary conditions
$$
u(0,t) = u(L,t) = 0, \qquad 0 < t,
$$
and initial condition
$$
u(x,0) = f(x).
$$
To solve this PDE, we can start by assuming that the solution is of the form $u(x,t) = X(x) T(t)$ to get a pair of ordinary differential equations that need to be solved instead, namely
\begin{align}
X'' + \lambda X &= 0,\\\\
T' + \lambda a^2 T &= 0.
\end{align}
By applying the boundary conditions, we can get the possible values of $\lambda$.
In this case, for each $n = 1, 2, 3, \dotsc$ we have
$$
\lambda_n = (n \pi / L)^2, \quad X_n(x) = \sin (n\pi x/L), \quad T_n = b_n e^{-(a n \pi/ L)^2 t}
$$
for some constants $b_n$.
Then, we say that the general solution is of the form
$$
u(x,t) = \sum_{n = 1}^\infty u_n(x,t) = \sum_{n=1}^\infty X_n(x) T_n(t) = \sum_{n = 1}^\infty b_n e^{-(an\pi/L)^2t}\sin(n\pi x/L).
$$
Lastly, we apply the given initial condition and solve for the Fourier coefficients $b_n$.
-----------
**Question**: Why does this method happen to work at all?
Relatedly, are there general conditions based on which we can recognize that separating variables will work? And, how do we know that this method finds all possible solutions to the given PDE whenever it is applicable?