Finite differencing
The first step in our numerical implementation of the solver is to discretize the spatial coordinates into grid points (or nodes). The one-dimensional case is shown in the figure below, where the x coordinate is discretized into Ngrid grid points:
If the distance between the grid points Δ x is constant, it can easily be seen that it is given by L/(Ngrid 1). With this arrangement, the second order derivative of ϕ at x = x0 can then be approximated by an algebraic equation:
where i is then the grid point located at x0. This approximation is said to be of second order accuracy and is considered to be a good approximation for sufficiently small Δ x, or equivalently, for a large number of grid points. Equation (6.9) is called the finite difference approximation to the second order derivative ∂2ϕ/∂x2. It comes from the basic definition of the derivative of a function, so no magic here. See the references listed in the beginning of this chapter, if you are curious.
If we...