Which initial functions can be solved by separation of variables consider the wave equation on $(0,\pi)$, i.e. let $f,g\in L^2(0,\pi)$ be two fixed functions and consider the following problem:
$$\partial_{tt}u=\partial_{xx}u, \quad x\in(0,\pi), t\in (0,\infty) \\ u(0,t)=u(\pi,t)=0, \\ u(x,0)=f(x);\quad \partial_t u=h.$$
When we separate variables we get the following special solutions of the differential equation $u_n(x,t)=\sin(nx)\left( A_n\cos(nt)+B_n\sin(nt) \right)$ satisfying the boundary conditions $u(0,t)=u(\pi,t)=0$.
Obviously any finite linear combination $u(x,t)=\sum_{1}^n u_n$ of the functions $u_n$ will still satisfy the PDE and the boundary conditions, even though one cannot always - depending of course on our choice of f and g- find constants $A_n, B_n$ such that $u$ will satisfy the initial conditions.
I am wondering what happens if one "sums up" all the functions $u_n$, i.e. if we consider $u_{\infty}(x,t):=\sum_{1}^{\infty}u_n(x,t)$? Then at least we can find coefficients $A_n, B_n$ such that the initial conditions are satisfied in the $L^2$ sense, for instance $u(x,0)$ will be equal to $f$ in the space $L^2.$ On the other hand - when we do consider infinite sequences- the question of differentiability of $u_{\infty}$ is unclear to me. 
Q:Is this function $u_{\infty}(x,t)$ a differentiable function and a solution of the PDE? Are there any instructive examples where this infinite sum happens to be not differentiable etc?
Further, I would like to know how "bad" the initial functions can be choosen so that $u_{\infty}$ will satisfies them pointwise, i.e. $u_{\infty}(x,0)=f(x,0), \partial_t u_{\infty}(x,0)=g(x,0)$ (pointwise, for some $A_n,B_n$)? Maybe there are instructive examples for this problem?
I would also very appreciate if someone can tell me good books which clarifies questions in the spirit of the above ones. 
Best wishes
 A: The separation of variables solutions are
$$
              u_n(x,t) = \sin(nx)\{ A_n\cos(nt)+B_n\sin(nt)\}
$$
In order to match the initial conditions
$$
          f(x)=u(x,0)=\sum_{n=1}^{\infty} u_n(0,t)=\sum_{n=1}^{\infty}A_n\sin(nx) \\
               \implies A_n = \frac{\int_{0}^{\pi}f(x)\sin(nx)dx}{\int_{0}^{\pi}\sin^2(nx)} = \frac{2}{\pi}\int_{0}^{\pi}f(x)\sin(nx)dx \\
          h(x)=u_t(x,0)=\sum_{n=1}^{\infty} (u_n)_t(0,x)=\sum_{n=1}^{\infty}nB_n\sin(nx) \\
  \implies B_n = \frac{2}{\pi n}\int_{0}^{\pi}h(x)\sin(nx)dx.
$$
The above is the proposed solution obtained by following the separation of variables procedure. It is convenient to work in $L^2[0,\pi]$, and it is physically realistic because of energy considerations. Suppose $h \in L^2$. Then
\begin{align}
    \frac{2}{\pi}\int_{0}^{\pi}h(x)^2dx
          & = \frac{2}{\pi}\int_{0}^{\pi}\left(\sum_{n=1}^{\infty}nB_n\sin(nx)\right)^2dx \\
          & = \sum_{n=1}^{\infty}n^2B_n^2 \frac{2}{\pi}\int_{0}^{\pi}\sin^2(nx)dx \\
          & = \sum_{n=1}^{\infty}n^2 B_n^2 \\
    \frac{2}{\pi}\int_{0}^{\pi}f(x)^2dx 
          & = \sum_{n=1}^{\infty}A_n^2.
\end{align}
The Separation of variables solution is
$$
             u(x,t)= \sum_{n=1}^{\infty}A_n\sin(nx)\cos(nt)+B_n\sin(nx)\sin(nt).
$$
For a fixed $t$ the sum $u(x,t)$ always converges in $L^2$ because $\sum_n A_n^2 < \infty$ and $\sum_n B_n^2 < \infty$. If you look at the solution using only Fourier Analysis, you don't get anything quite so nice as what you can get explicitly from the series expansion using trig identity:
$$
    \sin(nx)\cos(nt) = \frac{\sin(nx+nt)+\sin(nx-nt)}{2}
$$
Let $\tilde{f}$ and $\tilde{h}$ be the periodic extensions of $f$, $g$ from $[0,1]$ to $\mathbb{R}$. The solution is the superposition of a $\sin$ series $S(x,t)$ in $t$ and a $\cos$ series $C(x,t)$ in $t$. The cosine series is
\begin{align}
       C(x,t) & = \sum_{n=1}^{\infty}A_n \cos(nt)\sin(nx) \\
              & = \frac{1}{2}\sum_{n=1}^{\infty}A_n\sin(n(x+t))+A_n\sin(n(x-t)) \\
              & = \frac{1}{2}\{ \tilde{f}(x+t)+\tilde{f}(x-t)\}
\end{align}
The sine series is
$$
       S(x,t) = \sum_{n=1}^{\infty}B_n \sin(nt)\sin(nx)
$$
has a derivative a.e. in $t$ that converges in $L^2$ to
\begin{align}
   S_{t}(x,t) & =\sum_{n=1}^{\infty}nB_n\cos(nt)\sin(nx) \\
              & = \frac{1}{2}\sum_{n=1}^{\infty}B_n\sin(n(x+t))+B_n\sin(n(x-t)) \\
    & = \frac{1}{2}\{\tilde{h}(x+t)+\tilde{h}(x-t)\}.
\end{align}
So
$$
   u(x,t) = \frac{1}{2}\{\tilde{f}(x+t)+\tilde{f}(x-t)\}
      +\frac{1}{2}\int_{x-t}^{x+t}\tilde{h}(u)du
$$
