Consider the PDE $\dfrac{\partial^2 u}{\partial t^2} = c^2 \dfrac{\partial^2 u}{\partial x^2}$ with $c>0$ and boundary conditions u(0,t) = u(L,t) = 0 corresponding to the problem of a vibrating string fixed at two ends in physics.
By initial considerations, $u$ must be a twice differentiable real valued function, so we'd expect to look for solutions in $C^2(\mathbb{R})$.
Solving the PDE mechanically using common methods results in solutions
$$u(x,t) = \sum_{k=1}^{n} A_k \sin\left(\dfrac{\pi k x}{L}\right) \cos\left(\dfrac{\pi c k t}{L}\right) + B_k \sin\left(\dfrac{\pi k x}{L}\right) \sin\left(\dfrac{\pi c k t}{L}\right)$$
for arbitrary coefficients $A_k, B_k \in \mathbb{C}$. When convergence is guaranteed, infinite sums of this form qualify as solutions as well.
During the solution steps, as a trick, we allow $u$ to be complex valued along the way. Furthermore, the convergence of Fourier series is non-trivial and may further require extending $u$ to be in $L_2$. At this point, we're quite far from $C^2(\mathbb{R})$.
What are appropriate function spaces $X,Y$ for the domain and range of the operator $\left(\dfrac{\partial^2}{\partial t^2} - c^2 \dfrac{\partial^2}{\partial x^2}\right) : X \to Y$ when we are interested in physically realizable, real valued $u$?
If we set $X$ to be some space of real valued functions, how does the trick to extend $u$ to be complex valued work in full detail while solving the PDE? Similarly, in full detail, how are the obtained solutions restricted back to real valued functions?
How do we rigorously show that the solutions obtained above are all the solutions in the appropriate sense?
The functions $$ s_n(x)= \sqrt{\frac{2}{L}}\sin\left(\frac{n\pi x}{L}\right),\;\;\; n \ge 1, $$ form an orthonormal basis of $L^2[0,L]$, as do the functions $$ c_o(x)=\sqrt{\frac{1}{L}},\;\;c_n(x)=\sqrt{\frac{2}{L}}\cos\left(\frac{n\pi x}{L}\right),\;\;\; n \ge 1. $$ Your solution of the wave equation may be written as $$ u(x,t)=\sum_{n=1}^{\infty}\langle u(x,0),s_n\rangle s_n(x)c_n(t)+\sum_{n=0}^{\infty}\frac{L}{n\pi}\langle u_t(x,0),s_n\rangle s_n(x)s_n(t). $$ This expression for $u$ is consistent with $$ u(x,0)=\sum_{n=1}^{\infty}\langle u(x,0),s_n\rangle s_n(x), \\ u_t(x,0)=\sum_{n=1}^{\infty}\langle u_t(x,0),s_n\rangle s_n(x). $$ If $u(x,0),u_t(x,0)$ are specified as $L^2[0,L]$ functions, then $u(x,t)$ makes sense, though it takes some work to deal with the function $u$ classically. Working with $t\mapsto u(\cdot,t) \in L^2[0,L]$ turns out to be a useful model instead of thinking in terms of $u(x,t)$. This falls under $C_0$ semigroup theory if you keep the initial data $u(x,0),u_t(x,0)$ in $L^2$. And $L^2$ fits with Physics, too.