Solution of The Diffusion Equation by Finite Differences
Solution of The Diffusion Equation by Finite Differences
Solution of The Diffusion Equation by Finite Differences
next up previous Next: Numerical Solution of the Up: APC591 Tutorial 5: Numerical Previous: The Diffusion Equation
www.me.ucsb.edu//node3.html
1/5
4/14/2011
Figure 1: Grid for our finite difference approximations. The point labelled to Derivatives of are approximated in terms of the values of , etc.
corresponds
This derivative evaluated at the grid point simplest being the following: Forward Difference:
www.me.ucsb.edu//node3.html
2/5
4/14/2011
Backward Difference:
Central Difference:
at
as for the backward difference, let's imagine instead that we evaluate it at the , defined in the obvious way. Then, using central difference approximations for the
Then
www.me.ucsb.edu//node3.html
3/5
4/14/2011
(3)
We can approximate derivatives with respect to time in the same way. For example, the forward difference approximation for at the grid point is
(4)
It should be noted that these finite difference approximations are only valid to some order in or . The error in the approximations is called the truncation error. It is possible to get approximations which are valid to higher order by using more grid points in the approximations. This is all quite important, but for our purposes the approximations given above will be sufficient. Using the approximations (3) and (4) in (2), and rearranging, we get the following difference equation which can be iterated to find the approximate solution to equation (2): (5)
This is called an explicit numerical scheme because the computation of our computation of at
at
is completely determined by
. This scheme is also called consistent because the finite difference approximations , .
Although this is a consistent method, we are still not guaranteed that iterating equation (5) will give a good approximation to the true solution of the diffusion equation (2). A numerical scheme is called convergent if the solution of the discretized equations (here, the solution of (5)) approaches the exact solution (here, the solution of (2)) in the limit that , . For linear equations such as the diffusion equation, the issue of convergence is intimately related to the issue of stability of the numerical scheme (a scheme is called stable if it does not magnify errors that arise in the course of the calculation). Indeed, the Lax Equivalence Theorem says that for a properly posed initial value problem for a linear PDE, and a consistent finite difference approximation, stability is the necessary and sufficient condition for
www.me.ucsb.edu//node3.html 4/5
4/14/2011
convergence. Moreover, it can be shown that the scheme given by (5) is only convergent when (6)
These issues are also quite important, but this is not the appropriate place to go into them in more detail. All of the details are described, for example, in A First Course in Numerical Analysis of Differential Equations by Arieh Iserles, Cambridge University Press, 1996. However, before moving on, let me emphasize that as the sizes and are made smaller, the truncation error of approximating the partial derivatives by finite differences decreases. However, for smaller sizes, more computations need to be done to get solutions for the same domain and total time, which leads to increased roundoff error. The total error as a function of these sizes is sketched in Figure 2.
Figure 2: Sketch of errors as functions of the grid size for a finite difference calculation. Here it is assumed that the solution is calculated on the same domain and for the same total time. next up previous Next: Numerical Solution of the Up: APC591 Tutorial 5: Numerical Previous: The Diffusion Equation Jeffrey M. Moehlis 2001-10-24
www.me.ucsb.edu//node3.html
5/5