For example, consider the following problem
$$\frac{\partial u}{\partial t} = k\frac{\partial^2 u}{\partial x^2},\hspace{0.5cm} u(x,0)=f(x),\hspace{0.5cm} u(0,t)=0,\hspace{0.5cm} u(L,t)=0$$
Textbooks (e.g., [Paul's Online Notes](https://tutorial.math.lamar.edu/Classes/DE/SeparationofVariables.aspx)) usually apply separation of variables, assuming that $u(x,t)=\varphi(x)G(t)$ without any explanation why this assumption can be made.


Do we lose any solutions that way given that there are functions of two variables $x$ and $t$ that are not products of functions of individual variables?


Separation of variables gives the following solution when we consider only boundary conditions:
$$u\_n(x,t) = \sin\left(\frac{n\pi x}{L}\right)e^{-k\left(\frac{n\pi}{L}\right)^2t},\hspace{0.5cm}n=1,2,3,\dotsc.$$


The equation is linear, so we can take a superposition of $u\_n$:
$$u(x,t) = \sum\limits\_{n=1}^{\infty}B\_n\sin\left(\frac{n\pi x}{L}\right)e^{-k\left(\frac{n\pi}{L}\right)^2t}$$
where $B\_n$ are found from the initial condition:
$$B\_n = \frac{2}{L}\int\limits\_0^Lf(x)\sin\left(\frac{n\pi x}{L}\right)dx,\hspace{0.5cm}n=1,2,3,\dotsc.$$


Are there solutions $u(x,t)$ that cannot be represented this way (not for this particular pde but in general)? What happens in the case of non-linear equations? Can we apply separation of variables there?



Do we lose any solutions when applying separation of variables to partial differential equations?
Consider your purported solution $u(x,t)$ at fixed $t$, i.e., think of it as a function only of $x$. Such a function can be expanded in a complete set of functions $f\_n (x)$,
$$
u(x,t)=\sum\_{n} u\_n f\_n (x)
$$
What happens when you now choose a different fixed $t$? As long as the boundary conditions in the $x$ direction don't change (which is the case in your example), you can still expand in the same set $f\_n (x)$, so the only place where the $t$-dependence enters is in the coefficients $u\_n $ - they are what changes when you expand a different function of $x$ in the same set of $f\_n (x)$. So the complete functional dependence of $u(x,t)$ can be written as
$$
u(x,t)=\sum\_{n} u\_n (t) f\_n (x)
$$
Thus, when we make a separation ansatz, we are not assuming that our solutions are products. We are merely stating that we can construct a basis of product form in which our solutions can be expanded. That is not a restriction for a large class of problems. As is evident from the preceding argument, this goes wrong when the boundary conditions in the $x$ direction do depend on $t$ - then we cannot expand in the same set $f\_n (x)$ for each $t$. For example, if the domain were triangular such that the length of the $x$-interval depends on $t$, the frequencies in the sine functions in your example would become $t$-dependent.


