From Mathematica DSolve help pages. Solve the heat equation for \(u(x,t)\) on real line with \(t>0\)
With initial condition
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], t] == D[u[x, t], {x, 2}]; ic = u[x, 0] == E^(-x^2); sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic}, u[x, t], {x, t}], 60*10]];
Maple ✓
restart; pde := diff(u(x, t), t)=diff(u(x, t), x$2); ic := u(x,0)=exp(-x^2); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde,ic],u(x,t)) assuming t>0),output='realtime'));
Hand solution
Solve
On \(-\infty <x<\infty ,t>0\) with \(u\left ( x,0\right ) =f\left ( x\right ) =e^{-x^{2}}\). The first step is to find Green function for the above PDE. Taking Fourier transform of both sides w.r.t. \(x\), using \(\hat {u}\left ( k,t\right ) \) as the Fourier transform of \(u\left ( x,t\right ) \) gives
The solution to the above is
Therefore
And (1) becomes
To find Green function, we replace \(h\left ( x\right ) \) by \(\delta \left ( x-\xi \right ) \) where \(\xi \) is the location of the pulse. But \(\mathcal {F}\left ( \delta \left ( x-\xi \right ) ;k\right ) =\frac {1}{\sqrt {2\pi }}\int _{-\infty }^{\infty }\delta \left ( x-\xi \right ) e^{-ikx}dx=\frac {1}{\sqrt {2\pi }}e^{-i\xi k}\). Therefore the above becomes
The above is the Fourier transform of the Green function. Now we invert it
We would like to use Gaussian as the integrand, hence we want to change \(-i\xi k-k^{2}t+ikx\) to \(-\left ( k\sqrt {t}-A\right ) ^{2}\). We do this by completing the square.
Comparing sides then \(2Ak\sqrt {t}=k\left ( -i\xi +ix\right ) \) or \(A=\frac {-i\xi +ix}{2\sqrt {t}}\). Therefore
Hence
Substituting the above into (2) gives
To evaluate \(\int _{-\infty }^{\infty }e^{-\left ( k\sqrt {t}-\frac {-i\xi +ix}{2\sqrt {t}}\right ) ^{2}}dk\), let \(u=k\sqrt {t}\), then \(du=\sqrt {t}dk\). The above becomes
Now the integral is Gaussian. \(\int _{-\infty }^{\infty }e^{-\left ( u-\frac {-i\xi +ix}{2\sqrt {t}}\right ) ^{2}}du=\sqrt {\pi }\) and the above becomes
Now that we found the Green function for the PDE, we can find the solution as
But \(\int _{-\infty }^{\infty }e^{-\frac {\left ( x-\xi \right ) ^{2}}{4t}}e^{-\xi ^{2}}d\xi =\frac {2e^{-\frac {x^{2}}{1+4t}\sqrt {\pi }}}{\sqrt {\frac {1+4t}{t}}}\), hence the above becomes
___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
From Mathematica DSolve help pages. Solve the heat equation for \(u(x,t)\) on real line with \(t>0\)
With initial condition
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], t] == 12*D[u[x, t], {x, 2}] + Sin[t]*D[u[x, t], x]; ic = u[x, 0] == x; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic}, u[x, t], {x, t}], 60*10]];
Maple ✓
restart; pde := diff(u(x,t),t)= 12* diff(u(x,t),x$2)+sin(t)*diff(u(x,t),x); ic := u(x,0)=x; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde,ic],u(x,t))),output='realtime'));
___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
From Mathematica DSolve help pages. Solve the heat equation for \(u(x,t)\) on real line with \(t>0\)
With initial condition
Where UnitBox is equal to 1 if \(|x| \leq \frac {1}{2}\) and zero otherwise.
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], t] == D[u[x, t], {x, 2}]; ic = u[x, 0] == UnitBox[x]; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic}, u[x, t], {x, t}], 60*10]];
Maple ✓
restart; pde := diff(u(x, t), t)=diff(u(x, t), x$2); ic := u(x,0)=piecewise( x< -1/2 or x>1/2,0, 1); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde,ic],u(x,t)) assuming t>0),output='realtime'));
___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Solve the heat equation
For \(-\infty <x<\infty \) and \(t>0\), and initial condition is \(u(x,0)=f(x)\)
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], t] == k*D[u[x, t], {x, 2}]; ic = u[x, 0] == f[x]; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic}, u[x, t], {x, t}, Assumptions -> {t > 0, k > 0}], 60*10]]; sol[[2]] = sol[[2]] /. K[1] -> s;
Maple ✓
restart; interface(showassumed=0); pde := diff(u(x,t),t)=k*diff(u(x,t),x$2); ic := u(x,0)=f(x); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic],u(x,t)) assuming t>0,k>0),output='realtime'));
___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Solve the heat equation
For \(-\infty <x<\infty \) and \(t>0\). Initial condition is \(u(x,0)=\sin (x)\)
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], t] == k*D[u[x, t], {x, 2}] + m; ic = u[x, 0] == Sin[x]; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic}, u[x, t], {x, t}], 60*10]];
Maple ✓
restart; interface(showassumed=0); pde := diff(u(x,t),t)=k*diff(u(x,t),x$2)+m; ic := u(x,0)=sin(x); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic],u(x,t))),output='realtime'));
___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Solve the heat equation for \(u(x,t)\)
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], t] == D[u[x, t], {x, 2}]; sol = AbsoluteTiming[TimeConstrained[DSolve[pde, u[x, t], {x, t}], 60*10]];
Maple ✓
restart; pde := diff(u(x, t), t)=diff(u(x, t), x$2); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve(pde,u(x,t),'build') assuming t>0),output='realtime'));
Hand solution
Solve
for \(t>0,-\infty <x<\infty \). Let \(u=X\left ( x\right ) T\left ( t\right ) \) then we obtain
Dividing by \(XT\neq 0\)
(Only positive eigenvalues are possible). The two ODE’s are
Solution for (2) is \(X\left ( x\right ) =C_{1}e^{\sqrt {\lambda }x}+C_{2}e^{-\sqrt {\lambda }x}\) and solution for (1) is \(T\left ( t\right ) =C_{3}e^{-\lambda t}\). Hence
___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Added December 20, 2018.
Solve the heat equation for \(u(x,t)\) on real line with \(t>0\)
With initial condition
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], t] + 1 == mu*D[u[x, t], {x, 2}]; ic = u[x, 1] == Piecewise[{{1, x <= 0}, {0, x > 0}}]; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic}, u[x, t], x, t, Assumptions -> mu > 0], 60*10]];
Maple ✓
restart; pde := diff(u(x, t), t)+1 = mu* diff(u(x, t), x$2); ic := u(x, 1) = piecewise(0 <= x, 0, x < 0, 1); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde, ic],u(x,t)) assuming mu>0, t>0),output='realtime'));
Hand solution
Solve
for \(t>0,-\infty <x<\infty \) with initial conditions \(u\left ( x,0\right ) =f\left ( x\right ) =\left \{ \begin {array} [c]{cc}0 & x\geq 0\\ 1 & x<0 \end {array} \right . \)
Let \(v=u+t\). Hence \(u=v-t\) and \(u_{t}=v_{t}-1\) and \(u_{x}=v_{x}\) and \(u_{xx}=v_{xx}\). The above PDE becomes
Initial conditions do not change. They are \(v\left ( x,0\right ) =u\left ( x,0\right ) =\left \{ \begin {array} [c]{cc}0 & x\geq 0\\ 1 & x<0 \end {array} \right . \). Using Green function for 1D heat PDE on the real line, (also called heat Kernel)
Then the solution to (1) is
But \(\int _{0}^{\infty }e^{\frac {-\left ( x-x^{\prime }\right ) ^{2}}{4\mu t}}dx^{\prime }=\sqrt {\pi \mu t}\left ( 1+\operatorname {erf}\left ( \frac {x}{2\sqrt {\mu t}}\right ) \right ) \), hence
Since \(u=v-t\) then
___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Added May 23, 2019.
From Math 5587 midterm I, Fall 2016, practice exam, problem 14.
Solve for \(u(x,t)\) with IC \(u(x,0)=x\) for \(-\infty <x<\infty ,t>0\)
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], t] == D[u[x,t],{x,2}]; ic = u[x,0]==x; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde,ic}, u[x, t], {x, t}], 60*10]];