Return to computing page for the first course APMA0330
Return to computing page for the second course APMA0340
Return to computing page for the fourth course APMA0360
Return to Mathematica tutorial for the first course APMA0330
Return to Mathematica tutorial for the second course APMA0340
Return to Mathematica tutorial for the fourth course APMA0360
Return to the main page for the first course APMA0330
Return to the main page for the second course APMA0340
Return to the main page for the fourth course APMA0360
Return to Part VI of the course APMA0360
Introduction to Linear Algebra with Mathematica

Preface


Finite Difference for Heat Equations


Since one dimensional heat equation
\[ \frac{\partial u}{\partial t} = \alpha\frac{\partial^2 u}{\partial x^2} \]
contains second derivative, we need we look for a finite difference approximation to the second derivative, \( f ′′(x_0 ). Using Taylor's series, we have
\[ \begin{split} f \left( x_0 + \Delta x \right) &= f \left( x_0 \right) + f' \left( x_0 \right) \Delta x + \frac{1}{2}\, f'' \left( x_0 \right) \left( \Delta x \right)^2 + R_2^{+} , \\ f \left( x_0 - \Delta x \right) &= f \left( x_0 \right) - f' \left( x_0 \right) \Delta x + \frac{1}{2}\, f'' \left( x_0 \right) \left( \Delta x \right)^2 + R_2^{-} , \end{split} \]
where \( R_2^{\pm} . \) denote appropriate remainder terms. If we add both equations, divide by (∆x)² and ignore the remainder terms, we obtain the following finite difference approximation,
\[ f'' \left( x_0 \right) = \frac{f \left( x_0 - \Delta x \right) -2 f \left( x_0 \right) + f \left( x_0 + \Delta x \right) }{\left( \Delta x \right)^2} . \]
Because it involves x00 along with the points x0 ± ∆x on either side of it, this approximation is a centered difference approximation. ,/P.

 

We are going to demonstrate application of finite difference method to solve sme simple heat transfer equation, Namely, we consider homogeneous heat equation with no sources,
\begin{equation} \label{EqHeat.1} \frac{\partial u}{\partial t} = \alpha\frac{\partial^2 u}{\partial x^2} , \qquad 0 < x < \ell . \end{equation}
For the moment, the boundary conditions and initial conditions will be ignored.

We first form a grid on the x-axis by setting \( \displaystyle \Delta x = \frac{\ell}{N} > 0, \) for N > 0, and defining the grid points,

\begin{equation} \label{EqHeat.2} x_n = n\,\Delta x, \qquad n=0,1,2,\ldots , N. \end{equation}
We’ll also need to discretize the time variable: Let ∆t > 0 and define
\begin{equation} \label{EqHeat.3} t_k = k\,\Delta t, \qquad k=0,1,2,\ldots . \end{equation}
The finite difference scheme will be concerned with the values of u(x, t) on these grid points, i.e., the values u(xn, tk): For each n ≥ 0, the N + 1 set of values u(xn, tk), 0 ≤ nN , form a “snapshot” of the temperature function u on the spatial grid points xn.

or notational convenience, we use double scripts, with superscript for time variable:

\[ u_n^{(k)} = u( x_n , t_k ) \]
For time derivative, we employ the forward difference:
\[ \frac{\partial u}{\partial t} \left( x_n, t_k \right) \approx \frac{u( x_n , t_{k+1}) - u(x_n , t_k )}{\Delta t} = \dfrac{u_n^{(k+1)} - u_n^{(k)}}{\Delta t} . \]
The second spatial derivative is approximated by the following centered difference,
\[ \frac{\partial^2 u}{\partial x^2} \left( x_n, t_k \right) \approx \frac{u( x_{n+1} , t_{k}) - 2\, u(x_n , t_k ) + u(x_{n-1}, t_k )}{(\Delta x)^2} = \dfrac{u_{n+1}^{(k)} - 2\,u_n^{(k)} + u_{n-1}^{(k)}}{(\Delta x)^2} . \]
Substitution of these differences into the heat equation, Eq.\eqref{EqHeat.1}, and rearrangement yields the following difference scheme
\begin{equation} \label{EqHeat.4} u_n^{(k+1)} = u_n^{(k)} + \frac{k\,\Delta t}{\left( \Delta x \right)^2} \left[ u_{n+1}^{(k)} -2\,u_n^{(k)} + u_{n-1}^{(k)} \right] . \end{equation}

Crank--Nicholson Method


An important scheme, invented by John Crank and Phyllis Nicholson, is based on numerical approximations for solutions of heat equation at the point (n, t + ½(δ t) that lies between between the rows in the grid. Specifically, the approximation used for time derivative is obtained from the central difference formula,
\[ u_t \left( x, t + \frac{1}{2} \left( \Delta t \right) \right) = \frac{u(x, t + \Delta t) - u(x,t)}{\Delta t} + O \left( (\Delta t)^2 \right) . \]
a2i

 

Return to Mathematica page)
Return to the main page (APMA0360)
Return to the Part 1 Basic Concepts
Return to the Part 2 Fourier Series
Return to the Part 3 Integral Transforms
Return to the Part 4 Parabolic Differential Equations
Return to the Part 5 Hyperbolic Differential Equations
Return to the Part 6 Elliptic Equations
Return to the Part 7 Numerical Methods