Added July 12, 2019 Solve for \(u(x,t)\) with \(t>0\) and \(x>0\) \[ u_{tt} = c^2 u_{xx} \] With boundary conditions \begin {align*} u(0,t) &= 0 \end {align*}
With initial conditions \begin {align*} u_t(x,0) &=0 \\ u(x,0) &= f(x) \end {align*}
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t, 2}] == c^2*D[u[x, t], {x, 2}]; bc = u[0, t] == 0; ic = {u[x, 0] == f[x], Derivative[0, 1][u][x, 0] == 0}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}, Assumptions -> {t > 0,x > 0,c>0}], 60*10]];
\[\left \{\left \{u(x,t)\to \begin {array}{cc} \{ & \begin {array}{cc} \frac {1}{2} (f(x-c t)+f(c t+x)) & x>c t \\ \frac {1}{2} (f(c t+x)-f(c t-x)) & x\leq c t \\ \text {Indeterminate} & \text {True} \\\end {array} \\\end {array}\right \}\right \}\]
Maple ✗
restart; interface(showassumed=0); pde := diff(u(x,t),t$2)=c^2*diff(u(x,t),x$2); ic := u(x,0)=f(x),D[2](u)(x,0)=0; bc := u(0,t)=0; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic,bc],u(x,t),HINT = boundedseries(x=0)) assuming t>0,x>0,c>0),output='realtime'));
sol=()
Hand solution
Solving on semi-infinite domain for \(u(x,t)\)\begin {equation} \frac {\partial ^{2}u}{\partial t^{2}}=c^{2}\frac {\partial ^{2}u}{\partial x^{2}}\qquad 0<x<\infty ,t>0\tag {1} \end {equation} With BC \begin {align*} u\left ( 0,t\right ) & =0\\ u\left ( \infty ,t\right ) & <\infty \end {align*}
And initial conditions\begin {align*} u\left ( x,0\right ) & =f\left ( x\right ) \\ u_{t}\left ( x,0\right ) & =0 \end {align*}
Seperation of variables method
Let \(u\left ( x,t\right ) =X\left ( x\right ) T\left ( t\right ) \). The PDE in (1) becomes\[ \frac {T^{\prime \prime }}{c^{2}T}=\frac {X^{\prime \prime }}{X}=-\lambda \] Hence \begin {align*} X^{\prime \prime }+\lambda X & =0\\ X\left ( 0\right ) & =0\\ X\left ( \infty \right ) & <\infty \end {align*}
It is clear that \(\lambda \) can not be negative because it gives a solution that blows up. For \(\lambda =0\), the solution is \(X\left ( x\right ) =Ax+B\) and because \(X\left ( 0\right ) =0\) this implies \(B=0\). Hence solution is \(X\left ( x\right ) =Ax\). And this blows up as \(x\) increases unless \(A=0\). Hence \(\lambda =0\) is not valid eigenvalue. Therefore \(\lambda >0\). Let \(\lambda =\alpha ^{2},\alpha >0\) and the solution becomes\[ X\left ( x\right ) =A_{\alpha }\cos \left ( \alpha x\right ) +B_{\alpha }\sin \left ( \alpha x\right ) \] At \(x=0\) the above gives\[ 0=A_{\alpha }\] Therefore the solution becomes\begin {equation} X_{\alpha }\left ( x\right ) =B_{\alpha }\sin \left ( \alpha x\right ) \qquad \alpha >0\tag {1} \end {equation} The time domain ODE becomes\begin {align*} T^{\prime \prime }+c^{2}\alpha ^{2}T & =0\\ T & =C_{\alpha }\cos \left ( \alpha ct\right ) +D_{\alpha }\sin \left ( \alpha ct\right ) \\ T^{\prime }\left ( t\right ) & =-c\alpha C_{\alpha }\sin \left ( \alpha ct\right ) +c\alpha D_{\alpha }\cos \left ( \alpha ct\right ) \end {align*}
And at \(t=0,T^{\prime }\left ( 0\right ) =0\), hence the above becomes\[ 0=c\alpha D_{\alpha }\] Which means \(D_{\alpha }=0\). Therefore\begin {equation} T=C_{\alpha }\cos \left ( \alpha ct\right ) \qquad \alpha >0\tag {2} \end {equation} From (1,2) the complete solution is therefore\begin {equation} u\left ( x,t\right ) =\int _{0}^{\infty }A_{\alpha }\cos \left ( \alpha ct\right ) \sin \left ( \alpha x\right ) d\alpha \tag {3} \end {equation} Where \(A_{\alpha },C_{\alpha }\) are merged into one constant. Now the last initial condition is applied, which is \(u\left ( x,0\right ) =f\left ( x\right ) \) to the above which gives\[ f\left ( x\right ) =\int _{0}^{\infty }A_{\alpha }\sin \left ( \alpha x\right ) d\alpha \] Hence\[ A_{\alpha }=\frac {2}{\pi }\int _{0}^{\infty }f\left ( x\right ) \sin \left ( \alpha x\right ) dx \] Using the above in (3) gives the final solution as\[ u\left ( x,t\right ) =\frac {2}{\pi }\int _{0}^{\infty }\left ( \int _{0}^{\infty }f\left ( s\right ) \sin \left ( \alpha s\right ) ds\right ) \cos \left ( \alpha ct\right ) \sin \left ( \alpha x\right ) d\alpha \] D’Alambert’s formula method
For the half line, the D’Alambert’s is given by, using \(v_{0}\left ( x\right ) =u_{t}\left ( x,0\right ) \) as the initial velocity\[ u\left ( x,t\right ) =\left \{ \begin {array} [c]{ccc}\frac {1}{2}\left ( f\left ( x+ct\right ) +f\left ( x-ct\right ) \right ) +\frac {1}{2c}\int _{x-ct}^{x+ct}v_{0}\left ( s\right ) ds & & x>ct\geq 0\\ & & \\ \frac {1}{2}\left ( f\left ( x+ct\right ) -f\left ( ct-x\right ) \right ) +\frac {1}{2c}\int _{ct-x}^{x+ct}v_{0}\left ( s\right ) ds & & x\leq ct \end {array} \right . \] Hence, since \(u_{t}\left ( x,0\right ) =0\) in this problem\[ u\left ( x,t\right ) =\left \{ \begin {array} [c]{ccc}\frac {1}{2}\left ( f\left ( x+ct\right ) +f\left ( x-ct\right ) \right ) & & x>ct\geq 0\\ & & \\ \frac {1}{2}\left ( f\left ( x+ct\right ) -f\left ( ct-x\right ) \right ) & & x\leq ct \end {array} \right . \]
____________________________________________________________________________________
Taken from Mathematica DSolve help pages.
Solve for \(u(x,t)\) initial value wave PDE on infinite domain with \(t>0\) and \(x>0\). \[ u_{tt} = c^2 u_{xx} \] With initial conditions \begin {align*} u(x,0) &= \sin ^2(x) \hspace {20pt} \pi <x< 2\pi \\ \frac {\partial u}{\partial t}(x,0) &= 0 \end {align*}
And boundary conditions \(u(0,t)=0\)
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t, 2}] == c^2*D[u[x, t], {x, 2}]; ic = {u[x, 0] == Piecewise[{{Sin[x]^2, Pi < x < 2*Pi}}], Derivative[0, 1][u][x, 0] == 0}; bc = u[0, t] == 0; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t},Assumptions->c>0], 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 ^2(c t-x) & \pi <x-c t<2 \pi \\ 0 & \text {True} \\\end {array} \\\end {array}\right )+\left (\begin {array}{cc} \{ & \begin {array}{cc} \sin ^2(c t+x) & \pi <c t+x<2 \pi \\ 0 & \text {True} \\\end {array} \\\end {array}\right )\right ) & x>c t\geq 0 \\ \frac {1}{2} \left (\left (\begin {array}{cc} \{ & \begin {array}{cc} \sin ^2(c t+x) & \pi <c t+x<2 \pi \\ 0 & \text {True} \\\end {array} \\\end {array}\right )-\left (\begin {array}{cc} \{ & \begin {array}{cc} \sin ^2(c t-x) & \pi <c t-x<2 \pi \\ 0 & \text {True} \\\end {array} \\\end {array}\right )\right ) & 0\leq x\leq c t \\ \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)= piecewise(Pi<x and x<2*Pi,sin(x)^2),(D[2](u))(x,0)=0; bc := u(0,t)=0; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic,bc],u(x,t)) assuming t>0 and x>0),output='realtime'));
\[u \left ( x,t \right ) ={\frac {\begin {cases}\begin {cases}0 & ct+x\leq \pi \\ \left ( \sin \left ( ct+x \right ) \right ) ^{2} & ct+x<2\,\pi \\0 & 2\,\pi \leq ct+x\end {cases}-\begin {cases}0 & ct-x\leq \pi \\ \left ( \sin \left ( ct-x \right ) \right ) ^{2} & ct-x<2\,\pi \\0 & 2\,\pi \leq ct-x\end {cases} & x<ct\\\begin {cases}0 & ct+x\leq \pi \\ \left ( \sin \left ( ct+x \right ) \right ) ^{2} & ct+x<2\,\pi \\0 & 2\,\pi \leq ct+x\end {cases}+\begin {cases}0 & -ct+x\leq \pi \\ \left ( \sin \left ( ct-x \right ) \right ) ^{2} & -ct+x<2\,\pi \\0 & 2\,\pi \leq -ct+x\end {cases} & ct<x\end {cases}}{2}}\]
Hand solution
Solving on semi-infinite domain \begin {align} u_{tt} & =c^{2}u_{xx}\qquad t>0,x>0\tag {1}\\ u\left ( 0,t\right ) & =0\nonumber \\ u\left ( x,0\right ) & =f\left ( x\right ) =\sin ^{2}\left ( x\right ) \qquad \pi <x<2\pi \nonumber \end {align}
With \(k>0\) and \(u\left ( x,t\right ) <\infty \) as \(x\rightarrow \infty \). This means \(u\left ( x,t\right ) \) is bounded. The general solution to the above PDE was given in problem 5.1.2.1 on page 1370 as (using the D’Alambert’s solution and not the Fourier integral solution)\[ u\left ( x,t\right ) =\left \{ \begin {array} [c]{ccc}\frac {1}{2}\left ( f\left ( x+ct\right ) +f\left ( x-ct\right ) \right ) & & x>ct\geq 0\\ & & \\ \frac {1}{2}\left ( f\left ( x+ct\right ) -f\left ( ct-x\right ) \right ) & & x\leq ct \end {array} \right . \] But \(f\left ( x\right ) =\sin ^{2}\left ( x\right ) \) and the above becomes\[ u\left ( x,t\right ) =\left \{ \begin {array} [c]{ccc}\frac {1}{2}\left ( \sin ^{2}\left ( x+ct\right ) +\sin ^{2}\left ( x-ct\right ) \right ) & & x>ct\geq 0\\ & & \\ \frac {1}{2}\left ( \sin ^{2}\left ( x+ct\right ) -\sin ^{2}\left ( ct-x\right ) \right ) & & x\leq ct \end {array} \right . \] But here \(f\left ( x\right ) \) is restricted to \(\pi <x<2\pi \). Hence the above solution is modified as follows\[ u\left ( x,t\right ) =\left \{ \begin {array} [c]{ccc}\left \{ \begin {array} [c]{ccc}\frac {1}{2}\sin ^{2}\left ( x+ct\right ) & & \pi <x+ct<2\pi \\ 0 & & \text {otherwise}\end {array} \right . +\left \{ \begin {array} [c]{ccc}\frac {1}{2}\sin ^{2}\left ( x-ct\right ) & & \pi <x-ct<2\pi \\ 0 & & \text {otherwise}\end {array} \right . & & x>ct\geq 0\\ & & \\ \left \{ \begin {array} [c]{ccc}\frac {1}{2}\sin ^{2}\left ( x+ct\right ) & & \pi <x+ct<2\pi \\ 0 & & \text {otherwise}\end {array} \right . -\left \{ \begin {array} [c]{ccc}\frac {1}{2}\sin ^{2}\left ( ct-x\right ) & & \pi <ct-x<2\pi \\ 0 & & \text {otherwise}\end {array} \right . & & 0<x\leq ct \end {array} \right . \]
____________________________________________________________________________________
This is problem at page 115, David J Logan textbook, applied PDE textbook.
Falling cable lying on a table that is suddenly removed. \[ u_{tt} = c^2 u_{xx} - g \] With boundary condition \begin {align*} u(0,t) &= 0 \end {align*}
And initial conditions \begin {align*} u(x,0) &= 0 \\ \frac {\partial u}{\partial t}(x,0) &= 0 \end {align*}
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t, 2}] == c^2*D[u[x, t], {x, 2}] - g; bc = u[0, t] == 0; ic = {u[x, 0] == 0, Derivative[0, 1][u][x, 0] == 0}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}, Assumptions -> {t > 0, c > 0, x > 0}], 60*10]];
\[\left \{\left \{u(x,t)\to \frac {1}{2} g \left (\left (t-\frac {x}{c}\right )^2 \theta \left (t-\frac {x}{c}\right )-t^2\right )-c_1 \delta \left (t-\frac {x}{c}\right )\right \}\right \}\]
Maple ✓
restart; interface(showassumed=0); pde := diff(u(x,t),t$2)=c^2*diff(u(x,t),x$2)-g; ic :=D[2](u)(x,0)=0,u(0,t)=0,u(x,0)=0; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic],u(x,t),HINT = boundedseries) assuming t>0,x>0,c>0),output='realtime'));
\[u \left ( x,t \right ) ={\frac {g}{2\,{c}^{2}} \left ( {\it Heaviside} \left ( t-{\frac {x}{c}} \right ) \left ( ct-x \right ) ^{2}-{t}^{2}{c}^{2} \right ) }\]
____________________________________________________________________________________
Solve for \(u(x,t)\) with \(t>0\) and \(x>0\) \[ \frac {\partial ^2 u}{\partial t^2} = c^2 \frac {\partial ^2 u}{\partial x^2} \] With boundary conditions \begin {align*} u(0,t) &= g(t) \end {align*}
With initial conditions \begin {align*} \frac {\partial u}{\partial t}(x,0) &=0 \\ u(x,0) &= 0 \end {align*}
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t, 2}] == c^2*D[u[x, t], {x, 2}]; bc = u[0, t] == g[t]; ic = {u[x, 0] == 0, Derivative[0, 1][u][x, 0] == 0}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, 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} 0 & x>c t \\ g\left (t-\frac {x}{c}\right ) & x\leq c t \\ \text {Indeterminate} & \text {True} \\\end {array} \\\end {array}\right \}\right \}\]
Maple ✓
restart; interface(showassumed=0); pde := diff(u(x,t),t$2)=c^2*diff(u(x,t),x$2); ic := u(x,0)=0,D[2](u)(x,0)=0; bc := u(0,t)=g(t); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic,bc],u(x,t),HINT = boundedseries(x=0)) assuming t>0,x>0,c>0),output='realtime'));
\[u \left ( x,t \right ) ={\it invlaplace} \left ( {\it laplace} \left ( g \left ( t \right ) ,t,s \right ) {{\rm e}^{{\frac {sx}{c}}}},s,t \right ) \]
____________________________________________________________________________________
Taken from Mathematica DSolve help pages. Initial value problem with a Neumann condition on the half-line. \[ u_{tt} = c^2 u_{xx} \] With initial conditions \begin {align*} u(x,0) &= \sin ^3(x) \\ \frac {\partial u}{\partial t}(x,0) &= 1-e^{- \frac {x}{10}} \end {align*}
And boundary conditions \(\frac {\partial u}{\partial x}(0,t)=1\)
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t, 2}] == c^2*D[u[x, t], {x, 2}]; ic = {u[x, 0] == Sin[x]^3, Derivative[0, 1][u][x, 0] == 1 - E^(-(x/10))}; bc = Derivative[1, 0][u][0, t] == 1; sol = AbsoluteTiming[TimeConstrained[DSolveValue[{pde, ic, bc}, u[x, t], {x, t},Assumptions->c>0], 60*10]];
\[\left \{\left \{u(x,t)\to \begin {array}{cc} \{ & \begin {array}{cc} 0 & x>c t \\ g\left (t-\frac {x}{c}\right ) & x\leq c t \\ \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)= sin(x)^3,(D[2](u))(x,0)=1-exp(-x/10); bc:=(D[1](u))(0,t)=1; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic,bc],u(x,t)) assuming t>0 and x>0),output='realtime'));
\[u \left ( x,t \right ) ={\frac {1}{2\,c}\begin {cases} \left ( \sin \left ( ct+x \right ) \right ) ^{3}c- \left ( \sin \left ( ct-x \right ) \right ) ^{3}c+2\,ct-10\,{{\rm e}^{1/10\,ct-x/10}}+10\,{{\rm e}^{-1/10\,ct-x/10}} & ct<x\\10\,{{\rm e}^{-1/10\,ct-x/10}}+10\,{{\rm e}^{-1/10\,ct+x/10}}+ \left ( \sin \left ( ct-x \right ) \right ) ^{3}c+ \left ( \sin \left ( ct+x \right ) \right ) ^{3}c-20-2\,{c}^{2}t+ \left ( 2\,t+2\,x \right ) c & x<ct\end {cases}}\]
____________________________________________________________________________________
Added December 20, 2018.
Taken from https://www.mapleprimes.com/posts/209970-Exact-Solutions-For-PDE-And-Boundary--Initial-Conditions-2018 Solve \[ u_{tt} = u_{xx} \] With initial conditions \begin {align*} u(x,1) &= e^{-(x-6)^2}+e^{-(x+6)^2} \\ \frac {\partial u}{\partial t}(x,1) &= \frac {1}{2} \end {align*}
And boundary conditions \(\frac {\partial u}{\partial x}(0,t)=1\)
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t, 2}] == c^2*D[u[x, t], {x, 2}]; ic = {u[x, 1] == Sin[x]^3, Derivative[0, 1][u][x, 1] == 1 - E^(-(x/10))}; bc = Derivative[1, 0][u][0, t] == 1; sol = AbsoluteTiming[TimeConstrained[DSolveValue[{pde, ic, bc}, u[x, t], {x, t}, Assumptions -> t > 0], 60*10]];
\[\left \{\left \{u(x,t)\to \begin {array}{cc} \{ & \begin {array}{cc} 0 & x>c t \\ g\left (t-\frac {x}{c}\right ) & x\leq c t \\ \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, 1) = exp(-(x-6)^2)+exp(-(x+6)^2), eval(diff(u(x,t),t),t=1)= 1/2; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde, ic],u(x,t)) assuming t>0),output='realtime'));
\[u \left ( x,t \right ) ={\frac {{{\rm e}^{- \left ( 5-x+t \right ) ^{2}}}}{2}}+{\frac {{{\rm e}^{- \left ( -x+t-7 \right ) ^{2}}}}{2}}+{\frac {{{\rm e}^{- \left ( -7+x+t \right ) ^{2}}}}{2}}+{\frac {{{\rm e}^{- \left ( x+t+5 \right ) ^{2}}}}{2}}+{\frac {t}{2}}-{\frac {1}{2}}\]
____________________________________________________________________________________
Added December 20, 2018.
Solve \[ \frac {\partial ^2 u}{\partial t^2} = \frac {1}{4} \frac {\partial ^2 u}{\partial x^2} \] With initial conditions \begin {align*} u(x,0) &= e^{-x^2}\\ \frac {\partial u}{\partial t}(x,0) &= 0 \end {align*}
And Boundary conditions \(\frac {\partial u}{\partial x}(1,t)= 0\)
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t, 2}] == (1*D[u[x, t], {x, 2}])/4; ic = {u[x, 0] == Exp[-x^2], Derivative[0, 1][u][x, 0] == 0}; bc = Derivative[1, 0][u][1, t] == 0; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t}, Assumptions -> {t > 0, x > 0}], 60*10]];
\[\left \{\left \{u(x,t)\to \begin {array}{cc} \{ & \begin {array}{cc} e^{-x^2} & x-1\geq 0\land t=0 \\ \frac {2 \int _0^{\infty }\frac {1}{4} e^{-\frac {1}{4} K[1] (K[1]+4 i)} \sqrt {\pi } \cos \left (\frac {1}{2} t K[1]\right ) \cos ((x-1) K[1]) \left (\text {Erfc}\left (1-\frac {1}{2} i K[1]\right )+e^{2 i K[1]} \text {Erfc}\left (\frac {1}{2} i K[1]+1\right )\right )dK[1]}{\pi } & x-1\geq 0\land t>0 \\ \text {Indeterminate} & \text {True} \\\end {array} \\\end {array}\right \}\right \}\]
Maple ✓
restart; pde := diff(u(x, t), t$2)=(1/4)*(diff(u(x, t), x$2)); bc := eval(diff(u(x,t),x),x=1)=0; ic := u(x, 0) = exp(-x^2), eval(diff(u(x,t),t),t=0)=0; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde, ic,bc],u(x,t)) assuming x>0, t>0),output='realtime'));
\[u \left ( x,t \right ) ={\frac {1}{2}\begin {cases}{{\rm e}^{-{\frac { \left ( t+2\,x \right ) ^{2}}{4}}}}+{{\rm e}^{-{\frac { \left ( t-2\,x \right ) ^{2}}{4}}}} & {\frac {t}{2}}<-1+x\\{{\rm e}^{-{\frac { \left ( t+2\,x \right ) ^{2}}{4}}}}+{{\rm e}^{-{\frac { \left ( t-2\,x+4 \right ) ^{2}}{4}}}} & -1+x<{\frac {t}{2}}\end {cases}}\]
____________________________________________________________________________________
Added July 13, 2019.
Solve for \(u(x,t)\) with \(x>0,t>0\) \[ u_{tt} = c^2 u_{xx} \] With initial conditions \begin {align*} u(x,0) &= f(x)\\ \frac {\partial u}{\partial t}(x,0) &= 0 \end {align*}
And boundary condition \(\frac {\partial u}{\partial x}(0,t) = 0\).
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t, 2}] == c^2*D[u[x, t], {x, 2}]; ic = {u[x, 0] == f[x], Derivative[0, 1][u][x, 0] == 0}; bc = Derivative[1, 0][u][0, t] == 0; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t}, Assumptions -> {t > 0, x > 0,c>0}], 60*10]];
\[\left \{\left \{u(x,t)\to \begin {array}{cc} \{ & \begin {array}{cc} f(x) & x\geq 0\land t=0 \\ \frac {2 \int _0^{\infty }\cos (c t K[1]) \cos (x K[1]) \int _0^{\infty }\cos (x K[1]) f(x)dxdK[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)); bc := eval( diff(u(x,t),x),x=0)=0; ic := u(x,0)=f(x),eval(diff(u(x,t),t),t=0)=0; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde, bc,ic],u(x,t)) assuming x>0,t>0),output='realtime'));
\[u \left ( x,t \right ) ={\frac {\begin {cases}f \left ( ct+x \right ) +f \left ( -ct+x \right ) & ct<x\\f \left ( ct+x \right ) +f \left ( ct-x \right ) & x<ct\end {cases}}{2}}\]
____________________________________________________________________________________
Added July 14, 2019.
Solve for \(u(x,t)\) with \(x>0,t>0\) \[ u_{tt} = c^2 u_{xx} \] With initial conditions \begin {align*} u(x,0) &= f(x)\\ \frac {\partial u}{\partial t}(x,0) &= 0 \end {align*}
And boundary condition \(\frac {\partial u}{\partial x}(0,t) = 0\) using \begin {align*} c &= 3\\ f(x) &=\left \{ \begin {array} [c]{cc}1 & 4\leq x\leq 5\\ 0 & \text {otherwise}\end {array} \right . \end {align*}
Mathematica ✓
ClearAll["Global`*"]; c=3; f[x_]:=Piecewise[{{1,4<x<5},{0,True}}]; pde = D[u[x, t], {t, 2}] == c^2*D[u[x, t], {x, 2}]; ic = {u[x, 0] == f[x], Derivative[0, 1][u][x, 0] == 0}; bc = Derivative[1, 0][u][0, t] == 0; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t}, Assumptions -> {t > 0, x > 0}], 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 & 4<x-3 t<5 \\ 0 & \text {True} \\\end {array} \\\end {array}\right )+\left (\begin {array}{cc} \{ & \begin {array}{cc} 1 & 4<3 t+x<5 \\ 0 & \text {True} \\\end {array} \\\end {array}\right )\right ) & x>3 t \\ \frac {1}{2} \left (\left (\begin {array}{cc} \{ & \begin {array}{cc} 1 & 4<3 t-x<5 \\ 0 & \text {True} \\\end {array} \\\end {array}\right )+\left (\begin {array}{cc} \{ & \begin {array}{cc} 1 & 4<3 t+x<5 \\ 0 & \text {True} \\\end {array} \\\end {array}\right )\right ) & x\leq 3 t \\\end {array} \\\end {array}\right \}\right \}\]
Maple ✓
restart; c:=3; f:=piecewise(4<x and x<5,1,true,0); pde := diff(u(x, t), t$2) = c^2*(diff(u(x, t), x$2)); bc := eval( diff(u(x,t),x),x=0)=0; ic := u(x,0)=f(x),eval(diff(u(x,t),t),t=0)=0; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde, bc,ic],u(x,t)) assuming x>0,t>0),output='realtime'));
\[u \left ( x,t \right ) ={\frac {\begin {cases} \left ( \begin {cases}1 & 4<6\,t+x \land 6\,t+x<5\\0 & \text {otherwise}\end {cases} \right ) \left ( 3\,t+x \right ) + \left ( \begin {cases}1 & 4<x-6\,t \land x-6\,t<5\\0 & \text {otherwise}\end {cases} \right ) \left ( -3\,t+x \right ) & 3\,t<x\\ \left ( \begin {cases}1 & 4<6\,t+x \land 6\,t+x<5\\0 & \text {otherwise}\end {cases} \right ) \left ( 3\,t+x \right ) + \left ( \begin {cases}1 & 4<x \land x<5\\0 & \text {otherwise}\end {cases} \right ) \left ( 3\,t-x \right ) & x<3\,t\end {cases}}{2}}\]
Hand solution
Solve \(\frac {\partial ^{2}u}{\partial t^{2}}=c^{2}\frac {\partial ^{2}u}{\partial x^{2}}\) for \(x\geq 0,t\geq 0\) with initial conditions \(u\left ( x,0\right ) =f\left ( x\right ) =\left \{ \begin {array} [c]{cc}1 & 4\leq x\leq 5\\ 0 & \text {otherwise}\end {array} \right . \) and \(\frac {\partial u\left ( x,0\right ) }{\partial t}=0\) and boundary condition \(\frac {\partial u\left ( 0,t\right ) }{\partial x}=0\) (Free end)
The general solution by D’Almbert’s is given by\[ u\left ( x,t\right ) =\frac {1}{2}\left \{ \begin {array} [c]{ccc}f\left ( x+ct\right ) +f\left ( x-ct\right ) & & x>ct\geq 0\\ f\left ( x+ct\right ) +f\left ( ct-x\right ) & & x\leq ct \end {array} \right . \] But \(f\left ( x\right ) \) is defined for \(4\leq x\leq 5\) only, hence the solution becomes\[ u\left ( x,t\right ) =\left \{ \begin {array} [c]{ccc}\left \{ \begin {array} [c]{ccc}\frac {1}{2}f\left ( x+ct\right ) & & 4\leq x\leq 5\\ 0 & & \text {otherwise}\end {array} \right . +\left \{ \begin {array} [c]{ccc}\frac {1}{2}f\left ( x-ct\right ) & & 4\leq x\leq 5\\ 0 & & \text {otherwise}\end {array} \right . & & x>ct\geq 0\\ & & \\ \left \{ \begin {array} [c]{ccc}\frac {1}{2}f\left ( x+ct\right ) & & 4\leq x\leq 5\\ 0 & & \text {otherwise}\end {array} \right . +\left \{ \begin {array} [c]{ccc}\frac {1}{2}f\left ( ct-x\right ) & & 4\leq x\leq 5\\ 0 & & \text {otherwise}\end {array} \right . & & 0<x\leq ct \end {array} \right . \] Animation is below
Source code used for the above
____________________________________________________________________________________
Added January 9, 2020.
Solve for \(u(x,t)\) with \(x>0,t>0\) \[ u_{tt} = c^2 u_{xx} \] With initial conditions \begin {align*} u(x,0) &= f(x)\\ \frac {\partial u}{\partial t}(x,0) &= 0 \end {align*}
And boundary condition \(u(0,t) = 0\) using \begin {align*} c &= 3\\ f(x) &=\left \{ \begin {array} [c]{cc}1 & 4\leq x\leq 5\\ 0 & \text {otherwise}\end {array} \right . \end {align*}
Mathematica ✓
ClearAll["Global`*"]; c=3; f[x_]:=Piecewise[{{1,4<x<5},{0,True}}]; pde = D[u[x, t], {t, 2}] == c^2*D[u[x, t], {x, 2}]; ic = {u[x, 0] == f[x], Derivative[0, 1][u][x, 0] == 0}; bc = u[0, t] == 0; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t}, Assumptions -> {t > 0, x > 0}], 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 & 4<x-3 t<5 \\ 0 & \text {True} \\\end {array} \\\end {array}\right )+\left (\begin {array}{cc} \{ & \begin {array}{cc} 1 & 4<3 t+x<5 \\ 0 & \text {True} \\\end {array} \\\end {array}\right )\right ) & x>3 t \\ \frac {1}{2} \left (\left (\begin {array}{cc} \{ & \begin {array}{cc} 1 & 4<3 t+x<5 \\ 0 & \text {True} \\\end {array} \\\end {array}\right )-\left (\begin {array}{cc} \{ & \begin {array}{cc} 1 & 4<3 t-x<5 \\ 0 & \text {True} \\\end {array} \\\end {array}\right )\right ) & x\leq 3 t \\ \text {Indeterminate} & \text {True} \\\end {array} \\\end {array}\right \}\right \}\]
Maple ✓
restart; c:=3; f:=piecewise(4<x and x<5,1,true,0); pde := diff(u(x, t), t$2) = c^2*(diff(u(x, t), x$2)); bc := u(0,t)=0; ic := u(x,0)=f(x),D[2](u)(x,0)=0; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde, bc,ic],u(x,t)) assuming x>0,t>0),output='realtime'));
\[u \left ( x,t \right ) ={\frac {\begin {cases} \left ( \begin {cases}1 & 4<6\,t+x \land 6\,t+x<5\\0 & \text {otherwise}\end {cases} \right ) \left ( 3\,t+x \right ) - \left ( \begin {cases}1 & 4<x \land x<5\\0 & \text {otherwise}\end {cases} \right ) \left ( 3\,t-x \right ) & x<3\,t\\ \left ( \begin {cases}1 & 4<6\,t+x \land 6\,t+x<5\\0 & \text {otherwise}\end {cases} \right ) \left ( 3\,t+x \right ) + \left ( \begin {cases}1 & 4<x-6\,t \land x-6\,t<5\\0 & \text {otherwise}\end {cases} \right ) \left ( -3\,t+x \right ) & 3\,t<x\end {cases}}{2}}\]
Hand solution
Solve \(\frac {\partial ^{2}u}{\partial t^{2}}=c^{2}\frac {\partial ^{2}u}{\partial x^{2}}\) for \(x\geq 0,t\geq 0\) with initial conditions \(u\left ( x,0\right ) =f\left ( x\right ) =\left \{ \begin {array} [c]{cc}1 & 4\leq x\leq 5\\ 0 & \text {otherwise}\end {array} \right . \) and \(\frac {\partial u\left ( x,0\right ) }{\partial t}=0\) and boundary condition \(u\left ( 0,t\right ) =0\) (Fixed end)
The general solution by D’Almbert’s is given by\[ u\left ( x,t\right ) =\frac {1}{2}\left \{ \begin {array} [c]{ccc}f\left ( x+ct\right ) +f\left ( x-ct\right ) & & x>ct\geq 0\\ f\left ( x+ct\right ) -f\left ( ct-x\right ) & & x\leq ct \end {array} \right . \] But \(f\left ( x\right ) \) is defined for \(4\leq x\leq 5\) only, hence the solution becomes\[ u\left ( x,t\right ) =\left \{ \begin {array} [c]{ccc}\left \{ \begin {array} [c]{ccc}\frac {1}{2}f\left ( x+ct\right ) & & 4\leq x\leq 5\\ 0 & & \text {otherwise}\end {array} \right . +\left \{ \begin {array} [c]{ccc}\frac {1}{2}f\left ( x-ct\right ) & & 4\leq x\leq 5\\ 0 & & \text {otherwise}\end {array} \right . & & x>ct\geq 0\\ & & \\ \left \{ \begin {array} [c]{ccc}\frac {1}{2}f\left ( x+ct\right ) & & 4\leq x\leq 5\\ 0 & & \text {otherwise}\end {array} \right . +\left \{ \begin {array} [c]{ccc}-\frac {1}{2}f\left ( ct-x\right ) & & 4\leq x\leq 5\\ 0 & & \text {otherwise}\end {array} \right . & & 0<x\leq ct \end {array} \right . \] Animation is below
Source code used for the above
____________________________________________________________________________________
Added July 14, 2019.
Solve for \(u(x,t)\) with \(x>0,t>0\) \[ u_{tt} = c^2 u_{xx} \] With initial conditions \begin {align*} u(x,0) &= 0\\ \frac {\partial u}{\partial t}(x,0) &= g(x) \end {align*}
And boundary condition \(\frac {\partial u}{\partial x}(0,t) = 0\).
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t, 2}] == c^2*D[u[x, t], {x, 2}]; ic = {u[x, 0] == 0, Derivative[0, 1][u][x, 0] == g[x]}; bc = Derivative[1, 0][u][0, t] == 0; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t}, Assumptions -> {t > 0, x > 0,c>0}], 60*10]];
\[\left \{\left \{u(x,t)\to \begin {array}{cc} \{ & \begin {array}{cc} 0 & x\geq 0\land t=0 \\ \frac {2 \int _0^{\infty }\frac {\cos (x K[1]) \sin (c t K[1]) \int _0^{\infty }\cos (x K[1]) g(x)dx}{c 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)); bc := eval( diff(u(x,t),x),x=0)=0; ic := u(x,0)=0,eval(diff(u(x,t),t),t=0)=g(x); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde, bc,ic],u(x,t)) assuming x>0,t>0),output='realtime'));
\[u \left ( x,t \right ) ={\frac {\begin {cases}\int _{-ct+x}^{ct+x}\!g \left ( \zeta \right ) \,{\rm d}\zeta & ct<x\\\int _{0}^{ct+x}\!g \left ( \zeta \right ) \,{\rm d}\zeta +\int _{0}^{ct-x}\!g \left ( \zeta \right ) \,{\rm d}\zeta & x<ct\end {cases}}{2\,c}}\]
____________________________________________________________________________________
Added July 14, 2019.
Solve for \(u(x,t)\) with \(x>0,t>0\) \[ u_{tt} = c^2 u_{xx} \] With initial conditions \begin {align*} u(x,0) &= f(x)\\ \frac {\partial u}{\partial t}(x,0) &= g(x) \end {align*}
And boundary condition \(\frac {\partial u}{\partial x}(0,t) = 0\).
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t, 2}] == c^2*D[u[x, t], {x, 2}]; ic = {u[x, 0] == f[x], Derivative[0, 1][u][x, 0] == g[x]}; bc = Derivative[1, 0][u][0, t] == 0; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t}, Assumptions -> {t > 0, x > 0,c>0}], 60*10]];
\[\left \{\left \{u(x,t)\to \begin {array}{cc} \{ & \begin {array}{cc} f(x) & x\geq 0\land t=0 \\ \frac {2 \int _0^{\infty }\frac {\sqrt {\frac {\pi }{2}} \cos (x K[1]) \left (c \sqrt {\frac {2}{\pi }} \cos (c t K[1]) K[1] \int _0^{\infty }\cos (x K[1]) f(x)dx+\sqrt {\frac {2}{\pi }} \sin (c t K[1]) \int _0^{\infty }\cos (x K[1]) g(x)dx\right )}{c 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)); bc := eval( diff(u(x,t),x),x=0)=0; 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, bc,ic],u(x,t)) assuming x>0,t>0),output='realtime'));
\[u \left ( x,t \right ) ={\frac {1}{2}\begin {cases}f \left ( ct+x \right ) +f \left ( -ct+x \right ) +{\frac {\int _{-ct+x}^{ct+x}\!g \left ( \zeta \right ) \,{\rm d}\zeta }{c}} & ct<x\\{\frac {f \left ( ct-x \right ) c+f \left ( ct+x \right ) c+\int _{0}^{ct+x}\!g \left ( \zeta \right ) \,{\rm d}\zeta +\int _{0}^{ct-x}\!g \left ( \zeta \right ) \,{\rm d}\zeta }{c}} & x<ct\end {cases}}\]
____________________________________________________________________________________
Added December 20, 2018.
Example 17, Taken from https://www.mapleprimes.com/posts/209970-Exact-Solutions-For-PDE-And-Boundary--Initial-Conditions-2018
Left end free with initial position and velocity given.
Solve for \(u(x,t)\) with \(x>0,t>0\) \[ \frac {\partial ^2 u}{\partial t^2} = 9 \frac {\partial ^2 u}{\partial x^2} + f(x,t) \] With initial conditions \begin {align*} u(x,0) &= 0\\ \frac {\partial u}{\partial t}(x,0) &= x^3 \end {align*}
And boundary condition \(\frac {\partial u}{\partial x}(0,t) = 0\).
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], {t, 2}] == 9*D[u[x, t], {x, 2}]; ic = {u[x, 0] == 0, Derivative[0, 1][u][x, 0] == x^3}; bc = Derivative[1, 0][u][0, t] == 0; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t}, Assumptions -> {t > 0, x > 0}], 60*10]];
\[\left \{\left \{u(x,t)\to 3 c_1 \delta (3 t-x)+\frac {1}{12} (x-3 t)^4 \theta \left (t-\frac {x}{3}\right )+9 t^3 x+t x^3\right \}\right \}\]
Maple ✓
restart; pde := diff(u(x, t), t$2) = 9*(diff(u(x, t), x$2)); bc := eval( diff(u(x,t),x),x=0)=0; ic := u(x,0)=0,eval(diff(u(x,t),t),t=0)=x^3; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde, bc,ic],u(x,t)) assuming x>0,t>0),output='realtime'));
\[u \left ( x,t \right ) ={\frac {\begin {cases}108\,{t}^{3}x+12\,t{x}^{3} & 3\,t<x\\81\,{t}^{4}+54\,{t}^{2}{x}^{2}+{x}^{4} & x<3\,t\end {cases}}{12}}\]
____________________________________________________________________________________