## 2.4.5 General Finite Difference Approximations

Measurable Outcome 2.3, Measurable Outcome 2.8

So far we have developed several finite difference approximations for the first derivative and the central difference operator for the second derivative. As we've seen before for first and second derivative approximations, finite difference approximations may be obtained from the definition of the derivative. In practice, generating a finite difference approximation starting from the definition of the derivative can be difficult to extend to a variety of situations. For example, suppose that a backwards difference was desired for \(U_{x_ i}\) using three nodes. Mathematically, we want to find coefficients \(\alpha _ i\), \(\alpha _{i-1}\), and \(\alpha _{i-2}\) of \(U_ i\), \(U_{i-1}\), and \(U_{i-2}\) that would give an approximation to \(U_{x_ i}\), i.e.

Note, we have included a factor of \(1/\Delta x\) in this backwards finite difference approximation of the first derivative since we know that the formal definition of the first derivative involves calculating the difference of \(U(x+\Delta x/2)\) and \(U(x-\Delta x/2)\) dividing by \(\Delta x\). Doing this, the coefficients \(\alpha\) will not depend on \(\Delta x\). Now, we will utilize Taylor series to construct the truncation error for this approximation and then find the \(\alpha\) values that achieve the highest-order of accuracy. The necessary Taylor series expansions are,

Substituting these Taylor series into the three-point backwards difference formula and gathering the terms that are the same order in \(\Delta x\) gives,

Since we have 3 coefficients (\(\alpha _ i, \alpha _{i-1}, \alpha _{i-2}\)), we may choose these coefficients such that the terms multiplying \(U_{x_ i}\) sum to 1, while the terms multiplying \(\frac{1}{\Delta x} U_ i\) and \(\Delta x U_{xx_ i}\) sum to zero. Using matrix notation:

Thus the three-point backwards difference approximation for \(U_{x_ i}\) is equal to \((\frac{3}{2}U_ i - 2U_{i-1} + \frac{1}{2}U_{i-2})/\Delta x\). The truncation error can be found by substituting the \(\alpha\)'s in Equation 2.83 to show that,

Thus, this approximation for \(U_{x_ i}\) is second-order accurate. This approach can be generalized to the approximation of the \(k-th\) derivative,

where \(\alpha _ j\) are the coefficients for the finite difference approximation. \(\mathcal{S}\) is called the stencil, and contains the list of points used in the finite difference approximation. For example the central difference approximation, \(\delta _ x^2\), has a 3-point stencil using the nodal values \(U_{i-1}, U_ i\) and \(U_{i+1}\).

## Exercise

Give the coefficients \((\alpha _{i-2}, \alpha _{i-1}, \alpha _ i)\) of the highest-order accurate finite difference approximation for \(U_{xx_ i}\) using the 3-point stencil \((U_{i-2}, U_{i-1}, U_{i}\)).