Solve the following problem for a vibrating string of length $π$: Find a function $u(x, t), 0 ≤ x ≤ π, t ≥ 0$, satisfying
$∂^2u/dt^2 = ∂^2u/dx^2, 0 < x < π, t > 0$
the boundary conditions
$x(0, t) = x(π, t) = 0, t > 0,$
as well as the initial conditions
$u(x, 0) = \sin(2x), ∂u(x, 0)/∂t = −\sin(x) + \sin(3x), 0 ≤ x ≤ π$
The general solution of the wave equation has the form $u(x,t)=f(x+t)+g(x-t)$. The boundary conditions require $0=f(t)+g(-t)$ and $0=f(\pi+t)+g(\pi-t)$ giving $$ f(t)=-g(-t)=f(2\pi+t) $$ Thus $f$ is a $2\pi$ periodic function and at $t=0$ one gets \begin{align} \sin(2x)=u(x,0)&=f(x)+g(x)=f(x)-f(-x)\\ −\sin(x)+\sin(3x)=u_t(x,0)&=f'(x)-g'(x)=f'(x)-f'(-x) \end{align} where the second equation can be integrated to $$ \cos(x)-\frac13\cos(3x)+C=f(x)+f(-x)\\ \sin(2x)+\cos(x)-\frac13\cos(3x)+C=2f(x) $$ The integration constant $C$ cancels in $u(x,t)=f(x+t)-f(t-x)$.