Numerically Solving Partial Differential Equations

Christopher Lum
christopher.w.lum@gmail.com

This document accompanies the YouTube video at https://youtu.be/ZSNl5crAvsw.

Analytical Solution

Define the proposed analytical solution

p[t_,x_]=(1/(((2 π t))^(1/2)))Exp[- ((x^2)/(2 t))];

Check that this is the same as a Gaussian distribution with μ=0 and σ=(t^(1/2))

gaussian[x_,μ_,σ_]=(1/(σ (((2 π))^(1/2))))Exp[-(1/2)(((((x-μ)/σ)))^2)];

p[t,x]==gaussian[x,0,(t^(1/2))]

Verify that the solution solves the original PDE

D[p[t,x],t]==(1/2) D[p[t,x],{x,2}]//Simplify

Visualization

Visualize what the solution looks like as a function of time (see ‘Creating Movies and Animation in Mathematica’ YouTube video for more information)

(*Setup boundaries for the visualization*)
xMin=-5;
xMax=+5;
tMin=1/10;
tMax=10;

Manipulate[
Plot[p[t,x],{x,xMin,xMax},AxesLabel->{"x","p(t,x)"},PlotRange->{{xMin,xMax},{0,1.3}}],
{t,tMin, tMax}]