2.1.13 \(u_t + u_x = 0\) and \(u(x,0)=\sin x\) and \(u(0,t)=0\)

problem number 13

Taken from Mathematica help pages

Solve for \(u(x,t)\) \[ u_t + u_x = 0 \] with initial value \(u(x,0)=\sin x\) and boundary value \(u(0,t)=0\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] + D[u[x, t], x] == 0; 
bc  = u[0, t] == 0; 
ic  = u[x, 0] == Sin[x]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t}], 60*10]];
 

\[\{\{u(x,t)\to (\theta (t-x)-1) \sin (t-x)\}\}\]

Maple

restart; 
pde := diff(u(x,t),t)+diff(u(x,t),x)=0; 
bc  := u(0,t)=0; 
ic  := u(x,0)=sin(x); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic,bc],u(x,t)) assuming x>0),output='realtime'));
 

\[u \left ( x,t \right ) =-\sin \left ( -x+t \right ) {\it Heaviside} \left ( -t+x \right ) \]

Hand solution

Since initial and boundary conditions are given, the Laplace transform method will be used to solve this PDE. Let \(U\left ( x,s\right ) \) be the Laplace transform of \(u\left ( x,t\right ) \). Applying Laplace transform to the PDE gives\begin {align*} sU-u\left ( x,0\right ) +\frac {dU}{dx} & =0\\ \frac {dU}{dx}+sU & =\sin x \end {align*}

Integrating factor is \(\mu =e^{\int sdx}=e^{sx}\). Multiplying the above by \(\mu \) gives\[ \frac {d}{dx}\left ( Ue^{sx}\right ) =e^{sx}\sin x \] Integrating \begin {align*} Ue^{sx} & =\int e^{sx}\sin xdx+C\\ & =\frac {e^{sx}\left ( s\sin x-\cos x\right ) }{1+s^{2}}+C\\ U\left ( x,s\right ) & =\frac {s\sin x-\cos x}{1+s^{2}}+Ce^{-sx} \end {align*}

Applying boundary conditions \(U\left ( 0,s\right ) =0\) gives\begin {align*} 0 & =\frac {-1}{1+s^{2}}+C\\ C & =\frac {1}{1+s^{2}} \end {align*}

Hence \begin {align*} U\left ( x,s\right ) & =\frac {s\sin x-\cos x}{1+s^{2}}+\frac {e^{-sx}}{1+s^{2}}\\ & =\frac {s\sin x}{1+s^{2}}-\frac {\cos x}{1+s^{2}}+\frac {e^{-sx}}{1+s^{2}} \end {align*}

Applying inverse Laplace transform gives\begin {align*} u\left ( x,t\right ) & =\cos t\sin x-\cos x\sin t+\operatorname {Heaviside}\left ( t-x\right ) \sin \left ( t-x\right ) \\ & =-\sin \left ( t-x\right ) +\operatorname {Heaviside}\left ( t-x\right ) \sin \left ( t-x\right ) \\ & =\left ( \operatorname {Heaviside}\left ( t-x\right ) -1\right ) \sin \left ( t-x\right ) \end {align*}

____________________________________________________________________________________