## 2.4.4 Finite Difference Methods in Matrix Form

Measurable Outcome 2.3, Measurable Outcome 2.8

Consider the one-dimensional convection-diffusion equation,

Approximating the spatial derivative using the central difference operators gives the following approximation at node \(i\),

Assembling all of the nodal states into a single vector

gives a system of coupled ODEs of the form:

where \(b\) will contain the boundary condition related data. The matrix \(A\) has the form:

Note that row \(i\) of this matrix contains the coefficients of the nodal values for the ODE governing node \(i\). Except for rows requiring boundary condition data, the values of \(A_{i,j}\) are related to the coefficients \(\alpha _ j\) of the finite difference approximation. Specifically, for our central difference approximation

and all other entries of row \(i\) are zero. In general, the number of non-zero entries of row \(i\) will correspond to the size of the stencil of the finite difference approximations used. We refer to Equation 2.76 as being semi-discrete, since we have discretized the PDE in space but not in time. To make this a fully discrete approximation, we can apply any of the ODE integration methods that we discussed previously.

**Implementation Notes** When explicit methods are used to represent a FD method, then the \(A\) matrix does not need to be directly formed. Implementing a finite difference approximation at each node will suffice as we will only be interested in *matrix-vector multiplication*, i.e. we only need to *apply* \(A\).

On the other hand, implicit methods require the solution of a linear system. The solutions methods often require the representation of \(A\) as a matrix, and thus it must be constructed.