New in Wolfram Mathematica 7: Discrete Calculus  previous | next 
Solve a Discretized Partial Differential Equation
Visualize the smoothing of initial data for the heat equation using discretization.
In[1]:=

Click for copyable input
sol = With[{c = 1, k = 1/320, h = 0.08}, 

   RecurrenceTable[{v[i, j] == 

      c ((1 - (2 k)/h^2) v[i, j - 1] + (

         k (v[i + 1, j - 1] + v[i - 1, j - 1]))/h^2), 

     v[i, 0] == UnitStep[2. - i h] UnitStep[i h + 2] 100}, 

    v, {i, -70, 70}, {j, 0, 300}]];
In[2]:=

Click for copyable input
ListPlot3D[Transpose[sol], Mesh -> None, 

 PlotStyle -> {Orange, Specularity[White, 10]}, ImageSize -> 300, 

 AspectRatio -> 1]
Out[2]=