I am trying to solve the wave equation $${\partial ^2 u \over \partial x^2}={\partial ^2 u \over \partial t^2} \ , \ x\in[0,1] \ , \ t \in [0, 2] \tag 1$$
with the following initial and boundary conditions:
$$u(x,0) = 0 \tag 2$$ $${\partial u \over \partial t} \Bigg |_{t=0} =h(x)=\Bigg \{ \begin{matrix} k \ \ \mbox{if} \ \ x=0 \\ 0 \ \ \mbox{if} \ \ x > 0 \end{matrix} \tag 3$$
$$ {\partial u \over \partial x} \Bigg |_{x=0} = 0 \tag 4$$ $$ u(1, t) = 0 \tag5$$,
where $k=const$. I found some similar questions on the forum, but none of them took into consideration the boundary conditions, so I tried to find the solution on my own. However, I got stuck at a certain point. Here is what I did.
I wrote down the solution to this problem as a sum of a forward and backward traveling wave:
$$u(x, t) = f(t-x) + g(t+x) \tag 6$$
Next, I imposed the boundary condition $u(1, t) = 0$:
$$ f(t-1)+g(t+1) = 0\tag 7 $$
$$ -f(t-2)=g(t) \tag 8$$
$$ -f(t+x-2)=g(t+x) \tag 9$$
Then I wrote down the solution as:
$$u(x, t) = f(t-x) -f(t+x-2) \tag {10}$$
and redefined the conditions $(2)$, $(3)$ and (4):
$$ f(-x) -f(x-2) = 0 \tag {11}$$ $$ {df(t-x) \over d(t-x)} \Bigg |_{t=0}-{df(t+x-2) \over d(t+x-2)} \Bigg |_{t=0}=h(x) \tag {12}$$ $$ -{df(t-x) \over d(t-x)} \Bigg |_{x=0}-{df(t+x-2) \over d(t+x-2)} \Bigg |_{x=0}=0 \tag {13}$$
I got stuck at this point not knowing how to proceed. So my question is, what steps do I need to take to solve this problem?
As I wrote in my comment, it is simpler to solve the problem using the method of separation of variables. Since this is standard textbook material, I'll skip many details. The general solution to the $1D$ wave equation $u_{tt}-u_{xx}=0$ with boundary conditions $u_x(0,t)=0$, $u(1,t)=0$ is (check!) $$ u(x,t)=\sum_{n=0}^{\infty}\left[a_n\cos\left(n+\frac{1}{2}\right)\pi t +b_n\sin\left(n+\frac{1}{2}\right)\pi t\right]\cos\left(n+\frac{1}{2}\right)\pi x. \tag{1} $$ The initial condition $u(x,0)=0$ translates into $$ \sum_{n=0}^{\infty}a_n\cos\left(n+\frac{1}{2}\right)\pi x=0 \implies a_n=0\quad(n\in\mathbb{N}). \tag{2} $$ Similarly, $u_t(x,0)=h(x)$ implies $$ \sum_{n=0}^{\infty}\left(n+\frac{1}{2}\right)\pi b_n\cos\left(n+\frac{1}{2}\right)\pi x=h(x) $$ $$ \implies \left(n+\frac{1}{2}\right)\pi b_n=2\int_0^1h(x)\cos\left(n+\frac{1}{2}\right)\pi x\,dx\quad(n\in\mathbb{N}). \tag{3} $$ Finally, using the identity $\sin a\cos b=\frac{1}{2}[\sin(a-b)+\sin(a+b)],$ we can rewrite $(1)$ (with $a_n=0$) as $u(x,t)=f(t-x)+g(t+x)$, where $$ f(\xi)=g(\xi)=\frac{1}{2}\sum_{n=0}^{\infty}b_n\sin\left(n+\frac{1}{2}\right)\pi\xi. \tag{4} $$