Solution (source code)

= Solution

Set $y(x,t)=X(x)T(t)$ in the <wave equation>. A nonzero product obtained by <separation of variables> obeys
$$
\frac{X''}{X}=\frac{T''}{c^2T}=-k^2.
$$
The fixed-end <Dirichlet boundary conditions> require $X(0)=X(L)=0$. The zero and negative spatial <eigenvalue> cases produce only the trivial solution; the nontrivial <eigenfunctions> are
$$
X_n(x)=\sin\frac{n\pi x}{L},\qquad k_n=\frac{n\pi}{L},\qquad\omega_n=ck_n,\qquad n=1,2,\ldots.
$$
For each <normal mode>, $T_n''+\omega_n^2T_n=0$. By <superposition> and completeness of the <Fourier sine basis>, the general finite-energy solution has the expansion
$$
\boxed{y(x,t)=\sum_{n=1}^{\infty}\left[A_n\cos\omega_nt+B_n\sin\omega_nt\right]\sin\frac{n\pi x}{L}.}
$$
If $f(x)=y(x,0)$ and $g(x)=y_t(x,0)$, <orthogonality> gives $A_n=(2/L)\int_0^Lf(x)\sin(k_nx)\,dx$ and $B_n=2\int_0^Lg(x)\sin(k_nx)\,dx/(L\omega_n)$. Individual products are separable; their sum is the general solution.