STEP 29

NUMERICAL DIFFERENTIATION

Finite differences

In Analysis, we are usually able to obtain the derivative of a function by the methods of elementary calculus. However, if a function is very complicated or known only from values in a table, it may be necessary to resort to numerical differentiation.

  1. Procedure

    Formulae for numerical differentiation may easily be obtained by differentiating interpolation polynomials. The essential idea is that the derivatives f', f", . . . of a function are represented by the derivatives P'n, P"n, . . . of the interpolating polynomial Pn. For example, differentiation of Newton's forward difference formula (cf. STEP 22):

    with respect to x, since , etc., yields formally :

    In particular, if we set q = 0, we arrive at formulae for derivatives at the tabular points {xj}:

    .

    If we set q = ½, we have a relatively accurate formula at half-way points (without second differences):

    ;

    if we set = 1 in the formula for the second derivative, we find (without third differences):

    ,

    i.e., a formula for the second derivative at the next point.

    Note that, if one retains only one term, one arrives at the well-known formulae:

    ,

  2. Errors in numerical differentiation

    It must be recognized that numerical differentiation is subject to considerable error; the basic difficulty is that, while f (x) - Pn(x) may be small, the differences (f'(x) - Pn'(x)) and (f"(x-Pn"(x)), etc. may be very large. In geometrical terms, although two curves may be close together, they may differ considerably in slope, variation in slope, etc. (Figure 14).

    .

    FIGURE 14 Interpolating f(x)

    It should also be noted that all these formulae involve division of a combination of differences (which are prone to loss of significance or cancellation errors, especially if h is small) by a positive power of h. Consequently, if we want to keep round-off errors down, we should use a large value of h. On the other hand, it can be shown (see Exercise 3 below) that the truncation error is approximately proportional to hp, where p is a positive integer, so that k must be sufficiently small for the truncation error to be tolerable. We are in a cleft stick and must compromise with some optimum choice of h.

    In brief, large errors may occur in numerical differentiation, based on direct polynomial approximation, so that an error check is always advisable. There arc alternative methods, based on polynomials, which use more sophisticated procedures such as least-squares or mini-max, and other alternatives involving other basis functions (for example, trigonometric functions). However, the best policy is probably to use numerical differentiation only when it cannot be avoided!

  3. Example

    We will estimate the values of f'(0.1) and f"(0.1) for f(x) = ex, using the data in STEP 20.

    If we use the above formulae with = 0, we obtain (ignoring fourth and higher differences):

    .

    Since f"(0.1) = f''(0.1) = f (0.1) = 1.10517, it is obvious that the second result is much less accurate (due to round-off errors).

Checkpoint

  1. How are formula for the derivatives of a function obtained from interpolation formulae?
  2. Why is the accuracy of the usual numerical differentiation process not necessarily increased if the argument interval is reduced?
  3. When should numerical differentiation be used?

EXERCISES

1. Derive formulae involving backward differences for the first and second derivatives of a function.
2.The function is tabulated for x = 1.00(0.05)1.30 to 5D:

 

a. Estimate the values of f'(1.00) and f"(1.00), using Newton's forward difference formula.
b. Estimate f'(1.30) and f"(1.30), using Newton's backward difference formula.

3. Use Taylor series to find the truncation errors in the formulae:




Answers

last next