Solution (source code)

= Solution

For a separated solution $y=X(x)Q(t)$, the <wave equation> gives $X''/X=\ddot Q/(v^2Q)$. Choose the separation constant $-k^2$. Then
$$
X=A\cos kx+B\sin kx,\qquad Q=C\cos(vkt)+D\sin(vkt).
$$
These are the oscillatory separated building blocks. Since no endpoint conditions have yet been imposed, the general solution is a superposition over the allowed continuum of $k$, rather than one product with four constants. Equivalently, combining the left- and right-travelling separated components gives the <D'Alembert's formula>
$$
\boxed{y(x,t)=F(x-vt)+G(x+vt),}
$$
with arbitrary twice differentiable functions $F,G$ on the relevant characteristic intervals. Indeed, in characteristic coordinates $\xi=x-vt$, $\eta=x+vt$, the equation becomes $y_{\xi\eta}=0$, whose general solution is exactly this sum. This also includes zero-frequency and polynomial limits that would be omitted by restricting to one nonzero-$k$ sine mode.