Added May 26, 2019.
Solve for \(u(x,t)\) for all \(x\) and \(t>0\) with \(u(x,0)=f(x)\) and \(u_t(x,0)=g(x)\) \begin {align*} u_{tt} = u_{xx} \end {align*}
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t,2}] == D[u[x,t],{x,2}]; ic = {u[x,0]==f[x], Derivative[0,1][u][x,0]==g[x]}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde,ic}, u[x, t], {x, t}], 60*10]];
\[\left \{\left \{u(x,t)\to \begin {array}{cc} \{ & \begin {array}{cc} \frac {1}{2} (f(x-t)+f(t+x))+\frac {1}{2} \int _{x-t}^{t+x}g(K[1])dK[1] & t\geq 0 \\ \text {Indeterminate} & \text {True} \\\end {array} \\\end {array}\right \}\right \}\]
Maple ✓
restart; pde := diff(u(x,t),t$2)= diff(u(x,t),x$2); ic := u(x,0)=f(x), eval( diff(u(x,t),t),t=0)=g(x); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic],u(x,t))),output='realtime'));
\[u \left (x , t\right ) = \frac {\left (\int _{-t +x}^{t +x}g \left (\mathit {x1} \right )d \mathit {x1} \right )}{2}+\frac {f \left (-t +x \right )}{2}+\frac {f \left (t +x \right )}{2}\]
____________________________________________________________________________________
From Mathematica DSolve help pages (slightly modified)
Solve for \(u(x,t)\) with \(t>0\) on real line \[ u_{tt} + u_{xt} = c^2 u_{xx} \]
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t, 2}] + D[u[x, t], x, t] == c^2*D[u[x, t], {x, 2}]; sol = AbsoluteTiming[TimeConstrained[DSolve[pde, u[x, t], {x, t},Assumptions->c>0], 60*10]];
\[\left \{\left \{u(x,t)\to c_1\left (t-\frac {\left (\sqrt {4 c^2+1}-1\right ) x}{2 c^2}\right )+c_2\left (\frac {2 c^2 t+\sqrt {4 c^2+1} x+x}{2 c^2}\right )\right \}\right \}\]
Maple ✓
restart; interface(showassumed=0); pde := diff(u(x,t),t$2)+diff(u(x,t),t,x)=c^2*diff(u(x,t),x$2); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve(pde,u(x,t)) assuming t>0,x>0),output='realtime'));
\[u \left (x , t\right ) = \mathit {\_F1} \left (\frac {2 c^{2} t +\sqrt {4 c^{2}+1}\, x +x}{2 c^{2}}\right )+\mathit {\_F2} \left (\frac {2 c^{2} t -\sqrt {4 c^{2}+1}\, x +x}{2 c^{2}}\right )\]
____________________________________________________________________________________
Added December 20, 2018.
Solve \[ u_{tt}= c^2 u_{xx} + f(x,t) \] With initial conditions not at zero \begin {align*} u(x,1) &= g(x)\\ \frac {\partial u}{\partial t}(x,1) &= h(x) \end {align*}
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t, 2}] == c^2*D[u[x, t], {x, 2}]; ic = {u[x, 1] == g[x], Derivative[0, 1][u][x, 1] == h[x]}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic}, u[x, t], {x, t}, Assumptions -> {t > 0,c>0, x > 0}], 60*10]];
\[\left \{\left \{u(x,t)\to \begin {array}{cc} \{ & \begin {array}{cc} \frac {1}{2} \left (g\left (x-\sqrt {c^2} (t-1)\right )+g\left (\sqrt {c^2} (t-1)+x\right )\right )+\frac {\int _{x-\sqrt {c^2} (t-1)}^{\sqrt {c^2} (t-1)+x}h(K[1])dK[1]}{2 \sqrt {c^2}} & t-1\geq 0 \\ \text {Indeterminate} & \text {True} \\\end {array} \\\end {array}\right \}\right \}\]
Maple ✓
restart; pde := diff(u(x, t), t$2) = c^2*(diff(u(x, t), x$2)) + f(x, t); ic := u(x, 1) = g(x),eval(diff(u(x,t),t),t=1)=h(x); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde, ic], u(x, t)) assuming t>0, x>0),output='realtime'));
\[u \left (x , t\right ) = \frac {2 c g \left (x \right )+\left (2 t -2\right ) c h \left (x \right )+\int _{0}^{t -1}\int _{\left (-t +\tau +1\right ) c +x}^{\left (t -\tau -1\right ) c +x}\left (c^{2} \tau \left (\frac {d^{2}}{d \zeta ^{2}}h \left (\zeta \right )\right )+c^{2} \left (\frac {d^{2}}{d \zeta ^{2}}g \left (\zeta \right )\right )+f \left (\zeta , \tau +1\right )\right )d \zeta d \tau }{2 c}\]
____________________________________________________________________________________
Taken from Mathematica DSolve help pages.
Solve initial value wave PDE on infinite domain \[ u_{tt} = u_{xx} \] With initial conditions \begin {align*} u(x,0) &=e^{-x^2} \\ \frac {\partial u}{\partial t}(x,0) &= 1 \end {align*}
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t, 2}] == D[u[x, t], {x, 2}]; ic = {u[x, 0] == E^(-x^2), Derivative[0, 1][u][x, 0] == 1}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic}, u[x, t], {x, t}], 60*10]];
\[\left \{\left \{u(x,t)\to \begin {array}{cc} \{ & \begin {array}{cc} \frac {1}{2} \left (e^{-(x-t)^2}+e^{-(t+x)^2}\right )+t & t\geq 0 \\ \text {Indeterminate} & \text {True} \\\end {array} \\\end {array}\right \}\right \}\]
Maple ✓
restart; pde := diff(u(x,t), t$2) = diff(u(x,t), x$2); ic := u(x, 0) = exp(-x^2), (D[2](u))(x,0) = 1; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde, ic], u(x, t))),output='realtime'));
\[u \left (x , t\right ) = t +\frac {{\mathrm e}^{-\left (t -x \right )^{2}}}{2}+\frac {{\mathrm e}^{-\left (t +x \right )^{2}}}{2}\]
____________________________________________________________________________________
Taken from Mathematica DSolve help pages.
Solve initial value wave PDE on infinite domain \[ u_{tt} = u_{xx} + m \] With initial conditions \begin {align*} u(x,0) &=\sin x- \frac {\cos 3 x}{e^{ \frac {abs(x)}{6} }} \\ \frac {\partial u}{\partial t}(x,0) &= 0 \end {align*}
Mathematica ✓
ClearAll["Global`*"]; pde = {D[u[x, t], {t, 2}] == D[u[x, t], {x, 2}] + m}; ic = {u[x, 0] == Sin[x] - Cos[3*x]/E^(Abs[x]/6), Derivative[0, 1][u][x, 0] == 0}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic}, u[x, t], {x, t}], 60*10]];
\[\left \{\left \{u(x,t)\to \begin {array}{cc} \{ & \begin {array}{cc} \frac {1}{2} \left (m t^2-e^{-\frac {| t-x| }{6}} \cos (3 t-3 x)-e^{-\frac {| t+x| }{6}} \cos (3 (t+x))+2 \cos (t) \sin (x)\right ) & t\geq 0 \\ \text {Indeterminate} & \text {True} \\\end {array} \\\end {array}\right \}\right \}\]
Maple ✓
restart; pde := diff(u(x, t), t$2) = diff(u(x, t), x$2) + m; ic := u(x, 0) = sin(x) - cos(3*x)/exp(abs(x)/6), (D[2](u))(x, 0) =0; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde, ic], u(x, t))),output='realtime'));
\[u \left (x , t\right ) = \frac {\left (-\cos \left (3 t -3 x \right ) {\mathrm e}^{\frac {{| t +x |}}{6}}+\left (-\cos \left (3 t +3 x \right )+\left (m t^{2}-\sin \left (t -x \right )+\sin \left (t +x \right )\right ) {\mathrm e}^{\frac {{| t +x |}}{6}}\right ) {\mathrm e}^{\frac {{| t -x |}}{6}}\right ) {\mathrm e}^{-\frac {{| t -x |}}{6}} {\mathrm e}^{-\frac {{| t +x |}}{6}}}{2}\]
____________________________________________________________________________________
This was first solved analytically by (Krvskal, Zabrsky 1965).
Solve \[ u_t +6 u(x,t) u_x + u_{xxx} = 0 \]
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], t] + 6*u[x, t]*D[u[x, t], x] + D[u[x, t], {x, 3}] == 0; sol = AbsoluteTiming[TimeConstrained[DSolve[pde, u[x, t], {x, t}], 60*10]];
\[\left \{\left \{u(x,t)\to -\frac {12 c_1{}^3 \tanh ^2(c_2 t+c_1 x+c_3)-8 c_1{}^3+c_2}{6 c_1}\right \}\right \}\]
Maple ✓
restart; pde := diff(u(x,t),t)+6*u(x,t)*diff(u(x,t),x)+diff(u(x,t),x$3)=0; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve(pde,u(x,t)) assuming t>0,x>0),output='realtime'));
\[u \left (x , t\right ) = -2 c_{2}^{2} \left (\tanh ^{2}\left (c_{3} t +c_{2} x +c_{1}\right )\right )+\frac {8 c_{2}^{3}-c_{3}}{6 c_{2}}\]
Hand solution
Solve \[ u_{t}+6u\ u_{x}+u_{xxx}=0 \] Assuming special solution \(u=f\left ( \xi \right ) \) where \(\xi =x-ct\), this PDE is transformed to non-linear first order ODE\[ -c\frac {f^{2}}{2}+f^{3}+\frac {1}{2}\left ( \frac {df}{d\xi }\right ) ^{2}=0 \] The above is solved analytically (Krvskal, Zabrsky 1965) and the solution is\[ f\left ( x,c,t\right ) =\left ( \frac {1}{2}c\right ) \operatorname {sech}^{2}\left ( \frac {\sqrt {c}}{2}\left ( x-ct\right ) \right ) \] Tall waves move fast but have smaller period, while short wave move slow. Tall wave pass through short wave and leave in same shape they entered. Here are two animations and the above solution. This first animation has one tall wave passing though short wave
Source code used for the above
This animation shows three waves interacting
Source code used for the above
____________________________________________________________________________________
From Mathematica DSolve help pages. Inhomogeneous hyperbolic PDE with constant coefficients.
Solve for \(u(x,t)\) \[ 3 u_{xx}- u_{tt} + u_{xt}=1 \]
Mathematica ✓
ClearAll["Global`*"]; ode = 3*D[u[x, t], {x, 2}] - D[u[x, t], {t, 2}] + D[u[x, t], x, t] == 1; sol = AbsoluteTiming[TimeConstrained[DSolve[ode, u[x, t], {x, t}], 60*10]];
\[\left \{\left \{u(x,t)\to c_1\left (t-\frac {1}{6} \left (1+\sqrt {13}\right ) x\right )+c_2\left (t+\frac {1}{6} \left (\sqrt {13}-1\right ) x\right )+\frac {x^2}{6}\right \}\right \}\]
Maple ✓
restart; pde := 3*diff(u(x, t), x$2) - diff(u(x, t),t$2)+diff(u(x, t), x,t) =1; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve(pde, u(x, t))),output='realtime'));
\[u \left (x , t\right ) = -\frac {3 t^{2}}{13}+\frac {t x}{13}+\frac {x^{2}}{13}+\mathit {\_F1} \left (\frac {x}{2}+\frac {\left (-6 t +x \right ) \sqrt {13}}{26}\right )+\mathit {\_F2} \left (t +\frac {\left (-1+\sqrt {13}\right ) x}{6}\right )\]
____________________________________________________________________________________
Added May 23, 2019.
From Math 5587 midterm I, Fall 2016, practice exam, problem 10.
Solve for \(u(x,t)\) with \(u(x,0)=\sin (x)\) and \(u_t(x,0)=\cos (x)\) \begin {align*} u_{tt} = u_{xx} \end {align*}
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t,2}] == D[u[x,t],{x,2}]; ic = {u[x,0]==Sin[x], Derivative[0,1][u][x,0]==Cos[x]}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde,ic}, u[x, t], {x, t}], 60*10]];
\[\left \{\left \{u(x,t)\to \begin {array}{cc} \{ & \begin {array}{cc} \sin (t+x) & t\geq 0 \\ \text {Indeterminate} & \text {True} \\\end {array} \\\end {array}\right \}\right \}\]
Maple ✓
restart; pde := diff(u(x,t),t$2)= diff(u(x,t),x$2); ic := u(x,0)=sin(x), eval( diff(u(x,t),t),t=0)=cos(x); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic],u(x,t))),output='realtime'));
\[u \left (x , t\right ) = \sin \left (t +x \right )\]
____________________________________________________________________________________
Added May 23, 2019.
From Math 5587 midterm I, Fall 2016, practice exam, problem 11.
Solve for \(u(x,t)\) with \(u(x,0)=x^2\) and \(u_t(x,0)=x\) \begin {align*} u_{tt} = u_{xx} \end {align*}
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t,2}] == D[u[x,t],{x,2}]; ic = {u[x,0]==x^2, Derivative[0,1][u][x,0]==x}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde,ic}, u[x, t], {x, t}], 60*10]];
\[\left \{\left \{u(x,t)\to \begin {array}{cc} \{ & \begin {array}{cc} t^2+x t+x^2 & t\geq 0 \\ \text {Indeterminate} & \text {True} \\\end {array} \\\end {array}\right \}\right \}\]
Maple ✓
restart; pde := diff(u(x,t),t$2)= diff(u(x,t),x$2); ic := u(x,0)=x^2, eval( diff(u(x,t),t),t=0)=x; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic],u(x,t))),output='realtime'));
\[u \left (x , t\right ) = t^{2}+t x +x^{2}\]
____________________________________________________________________________________
Added May 23, 2019.
From Math 5587 midterm I, Fall 2016, practice exam, problem 12.
Solve for \(u(x,t)\) with \(u(x,0)=0\) and \(u_t(x,0)=\frac {4 x}{x^2+1}\) \begin {align*} u_{tt} = u_{xx} \end {align*}
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t,2}] == D[u[x,t],{x,2}]; ic = {u[x,0]==0, Derivative[0,1][u][x,0]==4*x/(x^2+1)}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde,ic}, u[x, t], {x, t}], 60*10]];
\[\left \{\left \{u(x,t)\to \begin {array}{cc} \{ & \begin {array}{cc} \log \left ((t+x)^2+1\right )-\log \left ((t-x)^2+1\right ) & t\geq 0 \\ \text {Indeterminate} & \text {True} \\\end {array} \\\end {array}\right \}\right \}\]
Maple ✓
restart; pde := diff(u(x,t),t$2)= diff(u(x,t),x$2); ic := u(x,0)=0, eval( diff(u(x,t),t),t=0)=4*x/(x^2+1); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic],u(x,t))),output='realtime'));
\[u \left (x , t\right ) = -\ln \left (t^{2}-2 t x +x^{2}+1\right )+\ln \left (t^{2}+2 t x +x^{2}+1\right )\]
____________________________________________________________________________________
Added January 9, 2020
Solve for \(u(x,t)\) with \(u(x,0)=\frac {1}{x^2+1}\) and \(u_t(x,0)=0\) \begin {align*} u_{tt} = u_{xx} \end {align*}
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t,2}] == D[u[x,t],{x,2}]; ic = {u[x,0]==1/(x^2+1), Derivative[0,1][u][x,0]==0}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde,ic}, u[x, t], {x, t}], 60*10]];
\[\left \{\left \{u(x,t)\to \begin {array}{cc} \{ & \begin {array}{cc} \frac {t^2+x^2+1}{t^4-2 \left (x^2-1\right ) t^2+\left (x^2+1\right )^2} & t\geq 0 \\ \text {Indeterminate} & \text {True} \\\end {array} \\\end {array}\right \}\right \}\]
Maple ✓
restart; pde := diff(u(x,t),t$2)= diff(u(x,t),x$2); ic := u(x,0)=1/(1+x^2), D[2](u)(x,0)=0; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic],u(x,t))),output='realtime'));
\[u \left (x , t\right ) = \frac {1}{2 \left (-t +x \right )^{2}+2}+\frac {1}{2 \left (t +x \right )^{2}+2}\]
Hand solution
Solve the wave equation \(u_{tt}=u_{xx}\) for infinite domain \(-\infty <x<\infty \) with initial position \(u\left ( x,0\right ) =\frac {1}{1+x^{2}}\) and zero initial velocity \(g\left ( x\right ) =0\).
The solution for wave PDE \(u_{tt}=a^{2}u_{xx}\) on infinite domain can be given as either series solution, or using D’Alembert solution. Using D’Alembert, the solution is\[ u\left ( x,t\right ) =\frac {1}{2}\left ( f\left ( x-at\right ) +f\left ( x+at\right ) \right ) +\frac {1}{2a}\int _{x-at}^{x+at}g\left ( s\right ) ds \] But here \(c=1\) and \(g\left ( x\right ) \) is zero. Therefore the above simplifies to\[ u\left ( x,t\right ) =\frac {1}{2}\left ( f\left ( x-t\right ) +f\left ( x+t\right ) \right ) \] Since \(f\left ( x\right ) =\frac {1}{1+x^{2}}\), the above becomes\[ u\left ( x,t\right ) =\frac {1}{2}\left ( \frac {1}{1+\left ( x-t\right ) ^{2}}+\frac {1}{1+\left ( x+t\right ) ^{2}}\right ) \]
Animation is below
Source code used for the above
____________________________________________________________________________________
Added January 10, 2020
Solve for \(u(x,t)\) with \(u(x,0)=\sin (x)\) from \(-\pi <x<\pi \) and zero everywhere else and \(u_t(x,0)=0\) \begin {align*} u_{tt} = u_{xx} \end {align*}
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t, 2}] == D[u[x, t], {x, 2}]; ic = {u[x, 0] == Piecewise[{{Sin[x], -Pi < x < Pi}, {0, True}}], Derivative[0, 1][u][x, 0] == 0}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde,ic}, u[x, t], {x, t}], 60*10]];
\[\left \{\left \{u(x,t)\to \begin {array}{cc} \{ & \begin {array}{cc} \frac {1}{2} \left (\left (\begin {array}{cc} \{ & \begin {array}{cc} -\sin (t-x) & t<x+\pi \land x<t+\pi \\ 0 & \text {True} \\\end {array} \\\end {array}\right )+\left (\begin {array}{cc} \{ & \begin {array}{cc} \sin (t+x) & -\pi <t+x<\pi \\ 0 & \text {True} \\\end {array} \\\end {array}\right )\right ) & t\geq 0 \\ \text {Indeterminate} & \text {True} \\\end {array} \\\end {array}\right \}\right \}\]
Maple ✓
restart; pde := diff(u(x,t),t$2)= diff(u(x,t),x$2); ic := u(x,0)= piecewise(-Pi<x and x<Pi,sin(x), true,0) , D[2](u)(x,0)=0; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic],u(x,t))),output='realtime'));
\[u \left (x , t\right ) = -\frac {\left (\left \{\begin {array}{cc}0 & -t +x \le -\pi \\\sin \left (t -x \right ) & -t +x <\pi \\0 & \pi \le -t +x \end {array}\right .\right )}{2}+\frac {\left (\left \{\begin {array}{cc}0 & t +x \le -\pi \\\sin \left (t +x \right ) & t +x <\pi \\0 & \pi \le t +x \end {array}\right .\right )}{2}\]
Hand solution
The solution for wave PDE \(u_{tt}=u_{xx}\) on infinite domain using D’Alembert solution with zero initial velocity is\begin {align*} u\left ( x,t\right ) & =\frac {1}{2}\left ( f\left ( x-t\right ) +f\left ( x+t\right ) \right ) \\ & =\frac {1}{2}\left ( \sin \left ( x-t\right ) +\sin \left ( x+t\right ) \right ) \end {align*}
The following is an animation Here is animation for 10 seconds.
Animation is below
Source code used for the above
____________________________________________________________________________________
Added May 26, 2019.
Taken from Final exam, Math 5587 UMN, Fall 2016.
Solve for \(u(x,t)\) for all \(x\) and \(t>0\) with \(u(x,0)=\sin (x)\) and \(u_t(x,0)=-2 x e^{-x^2}\) \begin {align*} u_{tt} = u_{xx} \end {align*}
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t,2}] == D[u[x,t],{x,2}]; ic = {u[x,0]==Sin[x], Derivative[0,1][u][x,0]==-2*x*Exp[-x^2]}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde,ic}, u[x, t], {x, t}], 60*10]];
\[\left \{\left \{u(x,t)\to \begin {array}{cc} \{ & \begin {array}{cc} \frac {1}{2} \left (2 \cos (t) \sin (x)-e^{-(t-x)^2}+e^{-(t+x)^2}\right ) & t\geq 0 \\ \text {Indeterminate} & \text {True} \\\end {array} \\\end {array}\right \}\right \}\]
Maple ✓
restart; pde := diff(u(x,t),t$2)= diff(u(x,t),x$2); ic := u(x,0)=sin(x), eval( diff(u(x,t),t),t=0)=-2*x*exp(-x^2); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic],u(x,t))),output='realtime'));
\[u \left (x , t\right ) = -\frac {{\mathrm e}^{-\left (t -x \right )^{2}}}{2}+\frac {{\mathrm e}^{-\left (t +x \right )^{2}}}{2}-\frac {\sin \left (t -x \right )}{2}+\frac {\sin \left (t +x \right )}{2}\]
____________________________________________________________________________________
Added Sept, 15, 2019.
Taken from Peter Olver textbook, Introduction to Partial differential equations. Problem 2.4.2
Solve for \(u(x,t)\) for all \(x\) and \(t>0\) with \(u(x,0)=1\) for \(1<x<2\) and zero otherwise. \(u_t(x,0)=0\) \begin {align*} u_{tt} = u_{xx} \end {align*}
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t,2}] == D[u[x,t],{x,2}]; ic = {u[x,0] == Piecewise[{{1, 1 < x < 2}, {0, True}}], Derivative[0,1][u][x,0]==0}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde,ic}, u[x, t], {x, t}], 60*10]];
\[\left \{\left \{u(x,t)\to \begin {array}{cc} \{ & \begin {array}{cc} \frac {1}{2} \left (\left (\begin {array}{cc} \{ & \begin {array}{cc} 1 & 1<x-t<2 \\ 0 & \text {True} \\\end {array} \\\end {array}\right )+\left (\begin {array}{cc} \{ & \begin {array}{cc} 1 & 1<t+x<2 \\ 0 & \text {True} \\\end {array} \\\end {array}\right )\right ) & t\geq 0 \\ \text {Indeterminate} & \text {True} \\\end {array} \\\end {array}\right \}\right \}\]
Maple ✓
restart; pde := diff(u(x,t),t$2)= diff(u(x,t),x$2); ic:=u(x,0)=piecewise(1<x and x<2,1,true,0),eval( diff(u(x,t),t),t=0)=0; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic],u(x,t))),output='realtime'));
\[u \left (x , t\right ) = \left (\left \{\begin {array}{cc}0 & -t +x \le 1 \\\frac {1}{2} & -t +x <2 \\0 & 2\le -t +x \end {array}\right .\right )+\left (\left \{\begin {array}{cc}0 & t +x \le 1 \\\frac {1}{2} & t +x <2 \\0 & 2\le t +x \end {array}\right .\right )\]
Hand solution
Solve the wave equation \(u_{tt}=u_{xx}\) when the initial displacement is the box function \(u\left ( 0,x\right ) =\left \{ \begin {array} [c]{ccc}1 & & 1<x<2\\ 0 & & \text {otherwise}\end {array} \right . \), while the initial velocity is zero.
Solution
d’Alembert solution of the wave equation is
\[ u\left ( t,x\right ) =\frac {1}{2}\left ( f\left ( x-ct\right ) +f\left ( x+ct\right ) \right ) +\frac {1}{2c}\int _{x-ct}^{x+ct}g\left ( s\right ) ds \]
Where \(c\) is the wave speed which is \(c=1\) in this problem and \(f\left ( x\right ) =u\left ( 0,x\right ) \) and \(g\left ( x\right ) =u_{t}\left ( 0,x\right ) =0\) in this problem. Hence the above simpifies to
\begin {align*} u\left ( t,x\right ) & =\frac {1}{2}\left ( f\left ( x-t\right ) +f\left ( x+t\right ) \right ) \\ & =\frac {1}{2}\left ( \left \{ \begin {array} [c]{ccc}1 & & 1<x-t<2\\ 0 & & \text {otherwise}\end {array} \right . +\left \{ \begin {array} [c]{ccc}1 & & 1<x+t<2\\ 0 & & \text {otherwise}\end {array} \right . \right ) \end {align*}
The following is an animation of the solution
Source code used for the above
____________________________________________________________________________________
Added Oct 8, 2019
Exam 1 problem, math 5587, fall 2019, UMN.
Solve for \(u(x,t)\) \begin {align*} u_{tt} = 4 u_{xx} +\cos (t) \end {align*}
With initial conditions \(u(x,0)=\sin x,u_t(x,0)=\cos x\)
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t,2}] == 4* D[u[x,t],{x,2}]+ Cos[t]; ic = {u[x,0]== Sin[x], Derivative[0,1][u][x,0]==Cos[x]}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde,ic}, u[x, t], {x, t}], 60*10]];
\[\left \{\left \{u(x,t)\to \begin {array}{cc} \{ & \begin {array}{cc} \sin (x) \cos ^2(t)+(\cos (x) \sin (t)-1) \cos (t)-\sin ^2(t) \sin (x)+1 & t\geq 0 \\ \text {Indeterminate} & \text {True} \\\end {array} \\\end {array}\right \}\right \}\]
Maple ✓
restart; pde := diff(u(x,t),t$2)= 4*diff(u(x,t),x$2)+cos(t); ic:=u(x,0)=sin(x),D[2](u)(x,0)=cos(x); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic],u(x,t))),output='realtime'));
\[u \left (x , t\right ) = -\cos \left (t \right )-\frac {\sin \left (2 t -x \right )}{4}+\frac {3 \sin \left (2 t +x \right )}{4}+1\]
Hand solution
Solve the wave equation \(u_{tt}=4u_{xx}+\cos t\) when initial conditions \(u\left ( x,0\right ) =\sin x,u_{t}\left ( x,0\right ) =\cos x\)
Solution
d’Alembert solution of the wave equation is\[ u\left ( t,x\right ) =\frac {1}{2}\left ( f\left ( x-ct\right ) +f\left ( x+ct\right ) \right ) +\frac {1}{2c}\int _{x-ct}^{x+ct}g\left ( s\right ) ds+\frac {1}{2c}\int _{0}^{t}\int _{x-c\left ( t-s\right ) }^{x+c\left ( t-s\right ) }F\left ( s\right ) dyds \] Where \(c\) is the wave speed which is \(c=2\) in this problem and \(f\left ( x\right ) =u\left ( 0,x\right ) =\sin x\) and \(g\left ( x\right ) =u_{t}\left ( 0,x\right ) =\cos x\) and the force \(F\left ( t\right ) =\cos t\) in this problem. Hence the above simpifies to\[ u\left ( t,x\right ) =\frac {1}{2}\left ( \sin \left ( x-2t\right ) +\sin \left ( x+2t\right ) \right ) +\frac {1}{4}\int _{x-2t}^{x+2t}\cos \left ( s\right ) ds+\frac {1}{4}\int _{0}^{t}\int _{x-2\left ( t-s\right ) }^{x+2\left ( t-s\right ) }\cos \left ( s\right ) dyds \] But \(\frac {1}{4}\int _{x-2t}^{x+2t}\cos \left ( s\right ) ds=\frac {1}{4}\left [ \sin \left ( s\right ) \right ] _{x-2t}^{x+2t}=\frac {1}{4}\left ( \sin \left ( x+2t\right ) -\sin \left ( x-2t\right ) \right ) \). Hence the above becomes\begin {align} u\left ( t,x\right ) & =\frac {1}{2}\left ( \sin \left ( x-2t\right ) +\sin \left ( x+2t\right ) \right ) +\frac {1}{4}\left ( \sin \left ( x+2t\right ) -\sin \left ( x-2t\right ) \right ) +\frac {1}{4}\int _{0}^{t}\int _{x-2\left ( t-s\right ) }^{x+2\left ( t-s\right ) }\cos \left ( s\right ) dyds\nonumber \\ & =\frac {1}{4}\sin \left ( x-2t\right ) +\frac {3}{4}\sin \left ( x+2t\right ) +\frac {1}{4}\int _{0}^{t}\int _{x-c\left ( t-s\right ) }^{x+c\left ( t-s\right ) }\cos \left ( s\right ) dyds\tag {1A} \end {align}
But \begin {align} \frac {1}{4}\int _{0}^{t}\int _{x-2\left ( t-s\right ) }^{x+2\left ( t-s\right ) }\cos \left ( s\right ) dyds & =\frac {1}{4}\int _{0}^{t}\cos \left ( s\right ) \int _{x-2\left ( t-s\right ) }^{x+2\left ( t-s\right ) }dyds\nonumber \\ & =\frac {1}{4}\int _{0}^{t}\cos \left ( s\right ) \left ( x+2\left ( t-s\right ) -x+2\left ( t-s\right ) \right ) ds\nonumber \\ & =\frac {1}{4}\int _{0}^{t}\cos \left ( s\right ) \left ( 2\left ( t-s\right ) +2\left ( t-s\right ) \right ) ds\nonumber \\ & =\frac {1}{4}\int _{0}^{t}\cos \left ( s\right ) \left ( 2t-2s+2t-2s\right ) ds\nonumber \\ & =\int _{0}^{t}\cos \left ( s\right ) \left ( t-s\right ) ds\nonumber \\ & =\int _{0}^{t}t\cos \left ( s\right ) ds-\int _{0}^{t}s\cos \left ( s\right ) ds\nonumber \\ & =t\left [ \sin \left ( s\right ) \right ] _{0}^{t}-\int _{0}^{t}s\cos \left ( s\right ) ds\nonumber \\ & =t\sin t-\int _{0}^{t}s\cos \left ( s\right ) ds\tag {1} \end {align}
Integration by parts. \(udv=uv-\int vdu\). Let \(u=s,dv=\cos s\), then \(du=1,v=\sin \left ( s\right ) \), then \begin {align} \int _{0}^{t}s\cos \left ( s\right ) ds & =\left [ s\sin \left ( s\right ) \right ] _{0}^{t}-\int _{0}^{t}\sin sds\nonumber \\ & =t\sin t-\left [ -\cos s\right ] _{0}^{t}\nonumber \\ & =t\sin t+\left ( \cos t-1\right ) \tag {2} \end {align}
Using (2) in (1) gives\begin {align*} \frac {1}{4}\int _{0}^{t}\int _{x-2\left ( t-s\right ) }^{x+2\left ( t-s\right ) }\cos \left ( s\right ) dyds & =t\sin t-\left ( t\sin t+\left ( \cos t-1\right ) \right ) \\ & =1-\cos t \end {align*}
Substituting the above in (1A) gives\[ u\left ( x,t\right ) =\frac {1}{4}\sin \left ( x-2t\right ) +\frac {3}{4}\sin \left ( x+2t\right ) +1-\cos t \] The following is an animation of the solution
Source code used for the above
____________________________________________________________________________________
Added January 8, 2020
Problem 6.3.27 Introduction to Partial Differential Equations by Peter Olver, ISBN 9783319020983.
Consider the wave equation \(u_{tt}=c^{2}u_{xx}\) on the line \(-\infty <x<\infty \). Use the d’Alembert formula to solve the initial value problem \(u\left ( x,0\right ) =\delta \left ( x-a\right ) ,u_{t}\left ( x,0\right ) =0\). \begin {equation} u\left ( x,t\right ) =\frac {1}{2}\left ( f\left ( x-ct\right ) +f\left ( x+ct\right ) \right ) +\frac {1}{2c}\int _{x-ct}^{x+ct}g\left ( s\right ) ds \tag {2.82} \end {equation}
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t, 2}] == c^2*D[u[x, t], {x, 2}]; ic = {u[x, 0] == DiracDelta[x - a], Derivative[0, 1][u][x, 0] == 0}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t}, Assumptions -> a > 0], 60*10]];
\[\left \{\left \{u(x,t)\to \begin {array}{cc} \{ & \begin {array}{cc} \delta (x-a) & x\geq 0\land t=0 \\ \frac {2 \int _0^{\infty }\cos (a K[1]) \cos \left (\sqrt {c^2} t K[1]\right ) \cos (x K[1])dK[1]}{\pi } & x\geq 0\land t>0 \\ \text {Indeterminate} & \text {True} \\\end {array} \\\end {array}\right \}\right \}\]
Maple ✓
restart; pde := diff(u(x,t),t$2)=c^2*diff(u(x,t),x$2); ic := u(x,0)=Dirac(x-a), D[2](u)(x,0)=0; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic],u(x,t)) assuming a>0),output='realtime'));
\[u \left (x , t\right ) = \frac {\delta \left (-c t +a -x \right )}{2}+\frac {\delta \left (c t +a -x \right )}{2}\]
Hand solution
\begin {equation} u\left ( x,t\right ) =\frac {1}{2}\left ( f\left ( x-ct\right ) +f\left ( x+ct\right ) \right ) +\frac {1}{2c}\int _{x-ct}^{x+ct}g\left ( s\right ) ds \tag {2.82} \end {equation}
In (2.82), the function \(f\) is the initial conditions and the function \(g\) is the initial velocity. Hence the above becomes\[ u\left ( x,t\right ) =\frac {1}{2}\left ( \delta \left ( \left ( x-a\right ) -ct\right ) +\delta \left ( \left ( x-a\right ) +ct\right ) \right ) \] But \(\delta \left ( \left ( x-a\right ) -ct\right ) =\delta \left ( x-a-ct\right ) =\delta \left ( x-\left ( a+ct\right ) \right ) \) and \(\delta \left ( \left ( x-a\right ) +ct\right ) =\delta \left ( x-a+ct\right ) =\delta \left ( x-\left ( a-ct\right ) \right ) \). Hence the above becomes\begin {equation} u\left ( x,t\right ) =\frac {1}{2}\delta \left ( x-\left ( a+ct\right ) \right ) +\frac {1}{2}\delta \left ( x-\left ( a-ct\right ) \right ) \tag {1} \end {equation} The above is two half strength delta pulses, one traveling to the left and one traveling to the right from the starting position.
____________________________________________________________________________________
From Mathematica DSolve help pages
Solve for \(u(x,t),v(x,t)\)
\begin {align*} \frac {\partial u}{\partial t} &= \frac {\partial v}{\partial x}+1\\ \frac {\partial v}{\partial t} &= -\frac {\partial u}{\partial x}-1 \end {align*}
With initial conditions \begin {align*} u(x,0) &= \cos ^2 x\\ v(x,0) &= \sin x \end {align*}
Mathematica ✓
ClearAll["Global`*"]; eqns = {D[u[x, t], t] == D[v[x, t], x] + 1, D[v[x, t], t] == -D[u[x, t], x] - 1}; ic = {u[x, 0] == Cos[x]^2, v[x, 0] == Sin[x]}; sol = AbsoluteTiming[TimeConstrained[FullSimplify[DSolve[{eqns, ic}, {u[x, t], v[x, t]}, {x, t}]], 60*10]];
\[\left \{\left \{u(x,t)\to \sinh (t) \cos (x)+\frac {1}{2} \cosh (2 t) \cos (2 x)+t+\frac {1}{2},v(x,t)\to \cosh (t) \sin (x) (2 \sinh (t) \cos (x)+1)-t\right \}\right \}\]