Wave equation with Neumann boundary condition I have the following problem:
$$
\begin{array}{ll}
&u_{tt}(x,t)=4u_{xx}(x,t),&x>0, t>0\\
&u_x(0,t)=-\cos(t),&t>0\\
&u(x,0)=e^{-x},&x>0\\
&u_t(x,0)=2e^{-x},&x>0.
\end{array}
$$
I am struggling to solve the above problem most likely because of the boundary condition. It is easy to get a solution to this problem if $x\in\mathbb{R}$ by applying d'Alembert's formula, for which I would get the solution $e^{-x+2t}$. However, this does not satisfy the boundary condition — only the initial conditions.
I tried to follow the derivation here without much luck possibly due to a lack of experience. Also, I tried to split the problem into two separate problems, firstly where $v(x,t)$ solves the wave equation PDE with homogeneous initial conditions and $v_x(0,t)=-\cos(t)$, and also $w(x,t)$ solves the wave equation with homogeneous boundary condition $w_x(0,t)=0$ and the desired initial conditions $w(x,0)=e^{-x}, w_t(x,0)=2e^{-x}$. Then, I should get $u(x,t)=v(x,t)+w(x,t)$. However, I ended up with $v(x,t)=\begin{cases}2\sin(t-x/2),&0\leq x\leq 2t\\0,&x>2t\end{cases}$, but was unable to solve for $w(x,t)$.
Any help would be greatly appreciated.
 A: It seems I was confused or made mistakes the first time trying to solve this, so I will post my solution now that it makes sense.
Assume $u(x,t)=F(x+2t)+G(x-2t)$. Then, the initial conditions give us:
$$
u(x,0)=F(x)+G(x)=e^{-x}\\
u_t(x,0)=2F'(x)-2G'(x)=2e^{-x}
$$
which hold for all $x>0$.
Hence, in the last equation, we may divide both sides by 2 and integrate with respect to x, then solve the resulting system:
$$
\begin{cases}
F(x)+G(x)=e^{-x}\\
F(x)-G(x)=-e^{-x}+C
\end{cases}
$$
where $C$ is some constant.
We thus obtain $F(x)=C/2$ and $G(x)=e^{-x}-C/2$. Since the only condition is that $x$ is positive, we may replace it by any positive quantity (I think this is where I was previously confused). Thus, we obtain $u(x,t)=F(x+2t)+G(x-2t)=C/2+e^{-(x-2t)}-C/2=e^{2t-x}$ which holds for all $x>2t$. It is clear, as I noted in my original post, that this corresponds to the same solution that we get from d'Alembert's formula.
Now we handle the case when the argument to $G$ is negative. For this, we need to use the boundary condition.
We have $u_x(0,t)=F'(2t)+G'(-2t)=-\cos t$ for all $t>0$. Make the substitution $z=-2t$ to obtain $G'(z)=-\cos(z/2)-F'(-z)=-\cos(z/2)$ by noting that $F'(-z)=0$ from our previous work. Integrating, we obtain $G(z)=-2\sin(z/2)+\tilde{C}$.
Applying the continuity condition, we must have $G(0)=\tilde{C}=1-C/2$. Thus, we have $u(x,t)=F(x+2t)+G(x-2t)=1-2\sin(x/2-t)$ for $0<x<2t$.
Hence, the complete solution is:
$$u(x,t)=\begin{cases}1-2\sin(x/2-t),&0<x\leq 2t\\e^{2t-x},&x>2t\end{cases}.$$
We can now verify that the initial conditions, boundary condition, and continuity are satisfied.
