## Topic 12.4: Higher-Order Derivatives

Introduction Notes Theory HOWTO Examples Engineering Error Questions Matlab Maple

Given three or more equally-spaced points, we can find an interpolating polynomial passing through those points, find the 2nd, 3rd, or even higher derivative of that polynomial, and evaluate the derivative at a point to get an approximation of the derivative at that point.

# Background

Useful background for this topic includes:

# References

• Bradie, Section 6.2, Numerical Differentiation, Part II, p.443.
• Mathews, Section 6.2, Numerical Differentiation Formulas, p.339.
• Chapra, Section 23.1, High-accuracy Differentiation Formaulas, p.632.

# Interactive Maplet

A Differentiation Formula Generator

To generate the formula for higher derivatives, select 2nd, 3rd, etc. instead of 1st in the third drop-down box.

# Theory

The theory for finding the nth-order derivatives is the same as that for finding simple derivatives: Given a sequence of equally spaced points (either around or preceding a given point x0), find the interpolating polynomial of the appropriate degree, differentiate the interpolating polynomial n times (instead of once) and evaluate that interpolating polynomial at the point.

For the sake of completeness, we will list the centred and backward divided-difference formulae here. In each case, the format of Richardson extrapolation we found could be used to improve the approximations for the O(h2) formulae on this page.

# Centred Divided-Difference Formulae

For each derivative, centred divided-difference formulae are O(h2) and O(h4), respectively.

# Backward Divided-Difference Formulae

For each derivative, backward divided-difference formulae are O(h) and O(h2), respectively. Note that in all cases, the O(h) formula is equivalent to the corresponding O(h2) centred divided-difference formula, only shifted by h.

# Problem

Approximate a higher derivative of a univariate function f(x) at a point x0. We will assume that we are given a sequence of points (xi, f(xi)) around the point of interest (either before or around). We will not look at iteration because the process of Richardson extrapolation converges significantly faster.

# Assumptions

We need to assume the function has an nth derivative if we are to bound the error on our approximation.

# Tools

We will use interpolation.

# Process

If we are to evaluate the second derivative at the point (xi, f(xi)) and have access to the two surrounding points, (xi − 1, f(xi − 1)) and (xi + 1, f(xi + 1)), then we may find the interpolating polynomial, differentiate it twice, and evaluate that derivative at xi:

This is simply another form of the formula

where h is the distance between the points, that is, h = xi - xi − 1.

If we have access to two points on either side of xi, we can calculate

where h = xi - xi − 1.

This is another form of the formula:

We could perform the same operations with higher derivatives, however, it should be noted that to calculate the nth derivative, we require at least n + 1 points.

# Example 1

Given the data points ..., 3.2, 3.3, 3.4, 3.5, 3.6, ... which measure the rotation of a satellite dish at points in time, with angles 1.05837 1.15775 1.25554 1.35078 1.44252, approximate the acceleration of the angle at time 3.4 using both the 2nd-order and 4th-order centred divided-difference formulae for the 2nd derivative.

(1.35078 − 2⋅1.25554 + 1.15775)/0.12 = −0.255 and (-1.44252 + 16⋅1.35078 − 30⋅1.25554 + 16⋅1.15775 − 1.05837)/(12⋅0.12) = −0.2550833333⋅⋅⋅.

Thus, −0.25508333333 is the more accurate answer, but even the 2nd-order formula is reasonably close.

To be completed.

# 2nd-Order Centred Divided-Difference Formula

To determine the error for the 2nd-order centred divided-difference formula for the second derivative, we need only look at the two Taylor series approximations:

and

Add these two equations and transfer the 2f(x) to the left-hand side to get

If we divide both sides by h2 and make the approximation that:

then we can rearrange the equation as

Thus, the error is O(h2).

# 4th-Order Centred Divided-Difference Formula

A similar sum may be used to find the error of the 4th-order divided difference formula. If you add the linear combination -f(x + 2h) + 8 f(x + h) - 8 f(x - h) + f(x - 2h) of the 5th-order Taylor series approximations, then, after dividing by 12h, we are left with the error term:

If we divide through by -1/30 and factor out the h4, we get

Now, examining the contents of the parentheses, we note that the coefficients 2/3 - 1/6 - 1/6 + 2/3 = 1, and therefore, the contents of the parentheses is an approximation of the average of f(5)(x) on the interval [x - 2h, x + 2h], and thus, we may approximate the error by

Thus, the error is O(h4).

# Question 1

Approximate the rate-of-change of the current at the midpoint of the incoming data ..., 7.2, 7.3, 7.4, 7.5, 7.6, ... where the charge on a capacitor these times is 0.00242759 0.00241500 0.00240247 0.00239001 0.00237761.

# Matlab

In Matlab, you would approximate the derivative numerically:

```>> ( sin( 1.7 ) - sin( 1.3 ) )/0.4
```

which would approximate the actual derivative of cos(1.5).

# Maple

Maple calculates derivatives symbolically:

```> diff( sin(x), x );
cos(x)
```

For more help on the diff routine, enter:

```?diff
```