Consider the following Cauchy problem
$$u_{tt} - c^2u_{xx} = 0$$
$$u(x,0) = \left\{\begin{matrix} 0 & \text{for}~x<0, \\ x^2 & \text{for}~x\geq0 \end{matrix}\right. $$
$$u_t(x,0) = 0$$
The D'Alembert solution is $u(x,t) = \frac 12(f(x-ct) + f(x + ct))$ which eventually leads to $u(x,t) = x^2 + c^2t^2 \quad\text{for} \ x \geq 0$. However, the answer sheet for the exercise gives the following solution for t>0:
$$u(x,t) = \left\{\begin{matrix} -x^2 -c^2t^2 & \text{for}~x<-ct, \\ 2ctx & \text{for}~-ct \geq x < ct \\ x^2 + c^2t^2 & \text{for}~x \geq ct \end{matrix}\right. $$
Please somebody show me how to acquire this solution because I'm stumped!
Given that
$$u(x,t) = \frac {1}{2}\big(u(x-ct,0) + u(x + ct,0)\big) = \frac {1}{2}\big(u(x-ct) + u(x + ct)\big)$$
You should break up the analysis into three cases substituting $(x−ct)$ and $(x+ct)$ for $x$ to evaluate
$$u(x-ct) = \left\{\begin{matrix} 0 & \text{for}~x<ct, \\ (x-ct)^2 & \text{for}~x\geqslant ct \end{matrix}\right. $$
$$u(x+ct) = \left\{\begin{matrix} 0 & \text{for}~x<-ct, \\ (x+ct)^2 & \text{for}~x \geqslant -ct \end{matrix}\right. $$
$\def\d{\mathrm{d}}$By d'Alembert's formula,
For $x < -ct$,$$ u(x, t) = \frac {1}{2}\big(u(x-ct) + u(x + ct)\big)= \frac {1}{2}\big(0 + 0\big)=0 $$ For $-ct \leqslant x < ct$,$$ u(x, t) = \frac {1}{2}\big(u(x-ct) + u(x + ct)\big)= \frac {1}{2}\big(0 + (x + ct)^2\big)=\frac {1}{2}\big(x + ct\big)^2 $$ For $x \geqslant ct$,$$ u(x,t)=\frac {1}{2}\big(u(x-ct) + u(x + ct)\big)=\frac{1}{2}\big((x-ct)^2 + (x + ct)^2\big)=x^2+c^2t^2 $$ Therefore$$ u(x, t) = \begin{cases} 0; & x < -ct\\ \frac {1}{2}\big(x + ct\big)^2; & -ct \leqslant x < ct\\ x^2+c^2t^2; & x \geqslant ct \end{cases} $$