$u_{tt}-4u_{xx}=0$ $x > 0, t > 0$
$u|_{t=0}=0 $
$u_t|_{t=0}= \begin{cases}\cos(x) && |x| < \pi/2 \\0 &&|x| \ge \pi/2\end{cases}$
General solution : $$u(x,t)=\frac{1}{2}\bigl[g(x+ct)+g(x-ct)\bigr]+
\frac{1}{2c}\int_{x-ct}^{x+ct} h(y)\,dy = \frac{1}{4}\int_{x-2t}^{x+2t} h(y)\,dy$$
when $(x-2t) \ge \frac{\pi}{2} $ and $(x+2t) \ge \frac{\pi}{2} $
$u = \frac{1}{4}\int_{x-2t}^{x+2t} 0\,dy = 0$
when $|x-2t| < \frac{\pi}{2} $ and $(x+2t) \ge \frac{\pi}{2} $
$u = \frac{1}{4}\int_{x-2t}^{x+2t} h(y)\,dy = \frac{1}{4}\int_{x-2t}^{\frac{\pi}{2}} \cos(y)\,dy + \frac{1}{4}\int_{\frac{\pi}{2}}^{x+2t} 0 \,dy = \frac{1}{4}(1 - \sin(x-2t)) $
when $(x-2t) \le \frac{-\pi}{2} $ and $(x+2t) \ge \frac{\pi}{2} $
$u = \frac{1}{4}\int_{x-2t}^{x+2t} h(y)\,dy = \frac{1}{4}\int_{\frac{\pi}{2}}^{x+2t} 0\,dy + \frac{1}{4}\int_{\frac{-\pi}{2}}^{\frac{\pi}{2}} \cos(y)\,dy + \frac{1}{4}\int_{x-2t}^{\frac{-\pi}{2}} 0\,dy = \frac{1}{2} $
when $|x-2t| < \frac{\pi}{2} $ and $|x+2t| < \frac{\pi}{2} $
$u = \frac{1}{4}\int_{x-2t}^{x+2t} \cos(y)\,dy = \frac{1}{4}(\sin(x+2t) - \sin(x-2t)) $