By using d'Alembert's formula, substitute $P(z)$ and $Q(z)$ into the general solution to obtain an expression for $u(x, t)$ We will define a motion that satisfies the equation: $$u_{tt} = c^2u_{xx}\qquad x ∈ (0, 1),\: t > 0$$We have the displacement of a string being $u(x, t)$, at position $x$ and time $t$, which is stretched between two fixed points at $x = 0$ and $x = 1$.
where $c$ is a real positive constant, and has boundary conditions
$$u(0, t) = u(1, t) = 0 \qquad t > 0$$
The string has an initial displacement $u(x, 0) = f(x), x ∈ (0, 1)$ and is initially at rest.
Starting with the general solution to the wave equation
$$u(x, t) = P(x − ct) + Q(x + ct)$$
for arbitrary functions $P(z)$ and $Q(z)$,
By obtaining expressions for $P(z)$ and $Q(z)$ in terms of $f(z)$ for all $z$, substitute these into the general solution to obtain an expression for $u(x, t)$ in the form $$u(x, t) = \frac{1}{2}(\overset{ˆ}{f}(x − ct) + \overset{ˆ}{f}(x + ct))$$
where $\overset{ˆ}{f}(z)$ is a suitable periodic extension of the initial data which should be defined.
Im really not sure how to approach this question even though ive being trying for a couple of hours now to solve it so any help will be apprecated.
 A: Since $u(x,t) = P(x - ct) + Q(x + ct)$, at $t = 0$ and $u(x,0) = f(x)$, we have:
$$f(x) = P(x) + Q(x) \ \ \ \ (\star)$$
Now note that differentiate with respect to $t$ gives:
$$\frac{\partial P}{\partial t} = \frac{\partial P}{\partial (x - ct)} \frac{\partial (x - ct)}{\partial t} = -c P' $$
And similarly, 
$$\frac{\partial Q}{\partial t} = c Q'$$
And
$$\frac{\partial u(x,t)}{\partial t} = \frac{\partial }{\partial t} \left[\frac 12 \left(\hat f (x - ct) + \hat f (x + ct)\right)\right] = \frac 12 \left( -c\hat f'(x - ct) + c\hat f'(x+ct)\right)$$
So $u_t(x,0) = \frac 12 \left( -c\hat f'(x) + c\hat f'(x)\right) = 0$.
Therefore,
$$u_t(x,0) = -cP'(x) + cQ'(x) = 0$$
Note that this implies $P'(x) = Q'(x)$. Integrate gives $P(x) = Q(x) + C$, where $C$ is a constant to be determined. 
Using the initial condition, $u(0,t) = 0$, we have that $u(0,0) = 0 = P(0) + Q(0)$, so $P(0) = -Q(0)$. Replace it back in to obtain $-Q(0) = Q(0) + C$ or $C = -2Q(0)$. 
Similarly, using $u(1,t) = 0$, we obtain $C = -2Q(1)$. 
But $Q$ is an arbitrary function (so $Q(0)$ is not necessarily $Q(1)$), this means $C = 0$. Note that if $Q(0) = Q(1)$, then $Q(x)$ is identically $0$, which does not give rise to a wave solution. In the end, we obtain:
$$P(x) - Q(x) = 0 \ \ \ \ (\star \star)$$
Combining $(\star)$ and $(\star \star)$, we get $P(x) = Q(x) = \frac 12 f(x)$. Now substitute back to get the form:
$$u(x,t) = P(x-ct) + Q(x+ct) = \frac 12 \left[f(x - ct) + f(x+ct)\right]$$
