Solution (source code)

= Solution

Put $u=ct-x$ and $v=ct+x$. The <chain rule> turns the <wave equation> into $4y_{uv}=0$. Integrating first in $v$ and then in $u$ gives the <D'Alembert formula>
$$
y(x,t)=f(ct-x)+g(ct+x).
$$
At the left endpoint, $g(u)=-f(u)$ for $u>0$. At the right endpoint, $f(ct-L)+g(ct+L)=0$, hence
$$
f(v+2L)=f(v)\qquad(v>-L).
$$
Thus the travelling waves can be represented by \b[$g=-f$, with $f$ and $g$ both $2L$-periodic]. More precisely, the positive-time boundary conditions constrain only $f$ on $(-L,\infty)$ and $g$ on $(0,\infty)$; their unused arguments may be filled in by this periodic extension. They do not constrain arbitrary pre-existing choices outside those ranges. This is <periodic reflection for a fixed-end string>.

Using $g=-f$, differentiation gives $y_t=c(f'(ct-x)-f'(ct+x))$ and $y_x=-f'(ct-x)-f'(ct+x)$. The cross terms in the <wave energy> cancel, so
$$
E(t)=\int_0^L\left(f'(ct-x)^2+f'(ct+x)^2\right)dx
=\int_{ct-L}^{ct+L}f'(s)^2\,ds.
$$
This integrates a $2L$-periodic function over exactly one period. \b[$E(t)$ is constant.] Equivalently, the <wave equation> gives $E'(t)=[y_ty_x]_0^L=0$, because the fixed endpoint values imply $y_t=0$ there.