Added Sept 12, 2019.
Taken from Peter Olver textbook, Introduction to Partial differential equations.
Solve \(u_t+2 u_x= \sin x\) with IC \(u(0,x)=\sin x\).
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[t, x], {t}] +2*D[u[t, x], {x}]== Sin[x]; ic = u[0,x]==Sin[x]; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde,ic}, u[t, x], {t, x}], 60*10]];
\[\left \{\left \{u(t,x)\to \frac {1}{2} (-2 \sin (2 t-x)+\cos (2 t-x)-\cos (x))\right \}\right \}\]
Maple ✓
restart; pde := diff(u(t, x), t) +2*diff(u(t, x),x) =sin(x); ic:=u(0,x)=sin(x); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic],u(t,x))),output='realtime'));
\[u \left ( t,x \right ) =-1/2\,\cos \left ( x \right ) -\sin \left ( 2\,t-x \right ) +1/2\,\cos \left ( 2\,t-x \right ) \]
Hand solution
Solve \begin {equation} u_{t}+2u_{x}=\sin x\tag {1} \end {equation} With initial conditions\(\ u\left ( x,0\right ) =\sin x\,\).
Solution
Let \(u=u\left ( x\left ( t\right ) ,t\right ) \). Then \begin {equation} \frac {du}{dt}=\frac {\partial u}{\partial x}\frac {dx}{dt}+\frac {\partial u}{\partial t}\tag {2} \end {equation} Comparing (1),(2) shows that \begin {align} \frac {du}{dt} & =\sin x\left ( t\right ) \tag {3}\\ \frac {dx}{dt} & =2\tag {4} \end {align}
Solving (3) gives\begin {equation} \int du=\int \sin x\left ( t\right ) dt\tag {3A} \end {equation} From (4)\[ x=2t+x\left ( 0\right ) \] Substituting the above into (3A) gives\begin {align} \int du & =\int \sin \left ( 2t+x\left ( 0\right ) \right ) dt\nonumber \\ u & =\frac {-\cos \left ( 2t+x\left ( 0\right ) \right ) }{2}+C\tag {3B} \end {align}
At \(t=0\) the above becomes\begin {align*} \sin \left ( x\left ( 0\right ) \right ) & =\frac {-\cos \left ( x\left ( 0\right ) \right ) }{2}+C\\ C & =\sin \left ( x\left ( 0\right ) \right ) +\frac {\cos \left ( x\left ( 0\right ) \right ) }{2} \end {align*}
Hence (3B) becomes\[ u=\frac {-\cos \left ( 2t+x\left ( 0\right ) \right ) }{2}+\sin \left ( x\left ( 0\right ) \right ) +\frac {\cos \left ( x\left ( 0\right ) \right ) }{2}\] But \(x\left ( 0\right ) =x-2t\), therefore\begin {align*} u\left ( x,t\right ) & =\frac {-\cos \left ( 2t+x-2t\right ) }{2}+\sin \left ( x-2t\right ) +\frac {\cos \left ( x-2t\right ) }{2}\\ & =\frac {-\cos \left ( x\right ) }{2}+\sin \left ( x-2t\right ) +\frac {\cos \left ( x-2t\right ) }{2} \end {align*}
An alternative approach to solve transport PDE is by using Lagrange-charpit method
\[ \frac {dt}{1}=\frac {dx}{2}=\frac {du}{\sin x}\] \(\frac {dt}{1}=\frac {dx}{2}\) gives \(\frac {dx}{dt}=2\) or \(x=2t+C_{1}\). Hence \[ C_{1}=x-2t \] And \(\frac {dx}{2}=\frac {du}{\sin x}\) gives \(\frac {du}{dx}=\frac {1}{2}\sin x\). Integrating gives \(u=\frac {-1}{2}\cos x+C_{2}\). Therefore \[ C_{2}=u+\frac {1}{2}\cos x \] But \(C_{2}=F\left ( C_{1}\right ) \) where \(F\) is arbitrary function. Therefore\begin {align} u+\frac {1}{2}\cos x & =F\left ( x-2t\right ) \nonumber \\ u\left ( t,x\right ) & =F\left ( x-2t\right ) -\frac {1}{2}\cos x \tag {1} \end {align}
When \(t=0\), \(u\left ( 0,x\right ) =\sin x\), therefore the above becomes\begin {align*} \sin x & =F\left ( x\right ) -\frac {1}{2}\cos x\\ F\left ( x\right ) & =\sin x+\frac {1}{2}\cos x\\ F\left ( z\right ) & =\sin z+\frac {1}{2}\cos z \end {align*}
Therefore the solution (1) can now be written as\begin {align*} u\left ( t,x\right ) & =\left ( \sin \left ( x-2t\right ) +\frac {1}{2}\cos \left ( x-2t\right ) \right ) -\frac {1}{2}\cos x\\ & =\sin \left ( x-2t\right ) +\frac {1}{2}\cos \left ( x-2t\right ) -\frac {1}{2}\cos x \end {align*}
The following is an animation of the solution
3D |
2D |
|
|
Source code used for the above
____________________________________________________________________________________