Solution (source code)

= Solution
{c}

Write $u(x,t)=U(\xi,\eta)$, where $\xi=x-t$ and $\eta=x+t$. The <chain rule> gives
$$
\partial_x=\partial_\xi+\partial_\eta,\qquad
\partial_t=-\partial_\xi+\partial_\eta.
$$
For a twice continuously differentiable <classical solution>, mixed <partial derivatives> commute, so the <wave equation> becomes
$$
0=u_{tt}-u_{xx}=-4U_{\xi\eta}.
$$
Hence $U_\xi$ depends only on $\xi$. Integrating first in $\xi$ yields the <countertravelling decomposition of the one-dimensional wave equation>:
$$
\boxed{u(x,t)=F(x-t)+G(x+t).}
$$
On a rectangular domain in $(\xi,\eta)$ this follows immediately; on the full line for $t\geq0$, the connected characteristic slices give the same representation. The two terms travel at <wave speed> one in opposite directions.

Impose the <initial conditions>. At $t=0$,
$$
F(x)+G(x)=f(x),\qquad -F'(x)+G'(x)=g(x).
$$
Differentiate the first identity and combine:
$$
F'(x)=\frac{f'(x)-g(x)}2,\qquad G'(x)=\frac{f'(x)+g(x)}2.
$$
If $H(x)=\int_{x_*}^xg(s)\,ds$, then $F=(f-H)/2+C$ and $G=(f+H)/2-C$. Substitution cancels $C$ and the arbitrary base point $x_*$, giving <D'Alembert's formula>:
$$
\boxed{u(x,t)=\frac{f(x-t)+f(x+t)}2+\frac12\int_{x-t}^{x+t}g(s)\,ds.}
$$
For example, $f\in C^2$ and $g\in C^1$ make this a <classical solution> of the <wave equation> satisfying both <initial conditions>. The same formula defines a <weak solution> for less regular data, including the continuous piecewise smooth data of part (b).