## Lecture 3.2:Difference formulas from interpolating polynomials

Derivatives can be approximated by difference formulas involving more than two or three adjacent points. Such higher-order difference approximations have a smaller truncation error and a comparable round-off error for the same step size h. There exists a general method to derive a multi-point difference approximation for the derivative I'(t0). The method consists of two steps: (i) construct a Lagrange or Newton interpolating polynomial I = P(t) through the given data set and (ii) take the derivative of the interpolating polynomial at the value t = t0. This method can be used even if the data values are not equally spaced, i.e. when the step size h is not uniform. The same method is also useful to derive multi-point finite difference approximations for second-order and higher-order derivatives.

### Three-point central difference

Let us derive a three-point central difference approximation for the derivative I'(t0) at the point (t0,I0), where two adjacent points (t-1,I-1) and (t1,I1) are located at a different non-uniform step size from the given point. The Newton interpolating polynomial through the three points is (see Lecture 2.2):

P2(t) = I0 + f[I0,I-1] (t - t0) + f[I0,I-1,I1] (t - t0) (t - t-1),

where f[I0,I-1] and f[I0,I-1,I1] are the first and second divided differences. By taking the derivative P'2(t0), we find the general three-point central difference approximation for the derivative I'(t0):

P'2(t0) = f[I0,I-1] + f[I0,I-1,I1] (t0 - t-1) =
(I0-I-1)(t1 - t0)/(t0 - t-1)(t1 - t-1) + (I0 - I1)(t0 - t-1)/(t0 - t1)(t1 - t-1).

If the step size is uniform, i.e. when the data values are equally spaced: h = t0 - t-1 = t1 - t0, this general three-point formula reduces to the central difference approximation introduced in Lecture 3.1. The truncation error of the interpolating polynomial I(t) = P2(t) is order of O(h3). By taking the derivative, the truncation error of the central difference approximation, I'(t0) = P'2(t0), becomes order of O(h2), which is indeed the truncation error of the three-point central difference approximation.

The same Newton polynomial P2(t) gives also the three-point central difference approximation for the second derivative: P''2(t0) = 2 f[I0,I-1,I1]. This approximation has the truncation order of O(h). When the step size is uniform, this approximation is improved due to the symmetry; the error becomes order of O(h2)). The second derivative is then approximated by:

I''(t0) = ( I1 - 2 I0 + I-1 ) / h2

The central difference approximation for the second derivative is important for further applications in partial differential equations.

### Three-point forward and backward differences

Let us continue the previous example and derive a three-point forward and backward difference approximations for the derivatives I'(t-1) and I'(t1), respectively. We take derivative of the Newton interpolating polynomial I = P2(t) and compute it at the points t = t-1 and t = t1:

P'2(t-1) = f[I0,I-1] + f[I0,I-1,I1] (t-1 - t0)
P'2(t1) = f[I0,I-1] + f[I0,I-1,I1] (2t1 - t0 - t-1)

If the step size is uniform, i.e. when the data values are equally spaced: h = t0 - t-1 = t1 - t0, the general three-point forward and backward difference formulas reduce to the form:

I'(t-1) = ( - 3 I-1 + 4 I0 - I1 ) / (2h)
I'(t1) = ( 3 I1 - 4 I0 + I-1 ) / (2h)

The three-point forward and backward difference approximations have also truncation errors of order O(h2). They are useful to approximate the derivative at the boundary (left-end and right-end) points at the same O(h2) order as the three-point central difference formula approximates the derivative at the interior points.

### Newton interpolation algorithm for derivatives

Consider the Newton interpolating polynomial I = Pn(t) through n+1 points: (tk,Ik) for k = 0,1,2,...,n. The difference approximation for the first derivative I'(t) at the point t can be found by differentiating the Newton polynomial Pn(t):

P'n(t) = f[I0,I1] + f[I0,I1,I2] ((t - t0) + (t - t1))
... + f[I0,I1,...,In] ((t - t1) ... (t - tn-1) + (t - t0) ... (t - tn-1) + ... (t - t0) ... (t - tn-2)).

The difference approximation for the derivative I'(t) = Pn(t) has the truncation error of order O(hn). The algorithm implemented below computes the derivative I'(t) at any point t from the derivative of the Newton interpolating polynomial P'n(t), where the points t0, t1, ..., tn are arbitrary ordered. The algorithm uses the same nested multiplication rule which is used for computing the Newton interpolating polynomial Pn(t). However, two nested multiplications are required for computing the derivative P'n(t). Similar algorithms can be designed to compute second and higher-order derivatives of the Newton interpolating polynomial.

MATLAB codes for computing derivative from the Newton interpolating polynomial
The algorithm is based on a double nested multiplication for polynomial evaluation