The basic idea of the finite differences method of solving PDEs is to replace
spatial and time derivatives by suitable approximations, then to numerically
solve the resulting difference equations. Specifically, instead of solving
for with and continuous, we solve for
, where
Derivatives of are approximated in terms of the values of at
grid points. For example, we know that
The second derivative at the grid point may be approximated by
using
We can approximate derivatives with respect to time in the same
way. For example, the forward difference approximation for
at the grid point is
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):
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
convergence. Moreover, it can be shown that the scheme given by
(5) is only convergent when
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.