STEP 21

INTERPOLATION 1

Linear and quadratic interpolation

Interpolation is the art of reading between the lines in a table. It may be regarded as a special case of the general process of curve fitting (Steps 26, Steps 28). More precisely, interpolation is the process whereby untabulated values of a function, given only at certain values, are estimated on the assumption that the function has sufficiently smooth behaviour between tabular points, so that it can be approximated by a polynomial of fairly low degree.

Interpolation is not as important in Numerical Analysis as it has been, now that computers (and calculators with built-in functions) are available, and function values may often be obtained readily by an algorithm (probably from a standard subroutine). However,

  1. interpolation is still important for functions that are available only in tabular form (perhaps from the results of an experiment); and
  2. interpolation serves to introduce the wider application of finite differences.

In Step 20, we have observed that, if the differences of order k are constant (within round-off fluctuation), the tabulated function may be approximated by a polynomial of degree k. Linear and quadratic interpolation correspond to the cases k = 1 and k = 2, respectively.

  1. Linear interpolation

    When a tabulated function varies so slowly that first differences are approximately constant, it may be approximated closely by a straight line between adjacent tabular points. This is the basic idea of linear interpolation. In Fig. 10, the two function points (xj, fj) and (xj+1, fj+1) are connected by a straight line. Any x between xj and xj+1 may be defined by a value of q such that

    If f (x) varies only slowly in the interval, a value of the function at x is approximately given by the ordinate to the straight line at x. Elementary geometrical considerations yield

    so that

    .

    FIGURE 10. Linear interpolation.

    In analytical terms, we have approximated f (x) by

    ,

    the linear function of x which satisfies

    ,

    As an example, consider the following difference table, taken from a 4D table of e-x:

    ,

    The first differences are almost constant locally, so that the table is suitable for linear interpolation. For example,

    .

  2. Quadratic interpolation

    As previously indicated, linear interpolation is appropriate only for slowly varying functions. The next simple process is quadratic interpolation, based on a quadratic approximating polynomial; one might expect that such an approximation would give better accuracy for functions with larger variations.

    Given three adjacent points xj, xj+1 = xj and xj+2 = xj + 2h, suppose that f (x) can be approximated by

    ,.

    where a, b, and c are chosen so that

    .

    Thus,

    .

    whence

    .

    Setting , we obtain the quadratic interpolation formula:

    .

    We note immediately that this formula introduces a second term (involving ), not included in the linear interpolation formula.

    As an example, we determine the second-order correction to the value of f (0.934) obtained above using linear interpolation. The extra term is

    so that the quadratic interpolation formula yields

    (In this case, the extra term -0.0024/200 is negligible!)

    Checkpoint

    1. What process obtains an untabulated value of a function?
    2. When is linear interpolation adequate?
    3. When is quadratic inteipolation needed and adequate?

    EXERCISES

    1. Obtain an estimate of sin(0.55) by linear interpolation of f (x) = sin x over the interval [0.5, 0.6] using the data:

      Compare your estimate with the value of sin(0.55) given by your calculator.

    2. The entries in a table of cos x are:

      .

      Obtain an estimate of cos(80° 35') by means of

      1. Linear interpolation,
      2. quadratic interpolation.
    3. The entries in a table of tan x are:

      Is it more appropriate to use linear or quadratic interpolation? Obtain an estimate of tan(80° 35').

Answers

last next