Interactive Educational Modules in
Scientific Computing

Numerical Differentiation

This module illustrates several methods for approximating the derivative of a function represented by a discrete set of points. All of the methods are based on fitting a smooth function to the data points, either by interpolation or by least squares approximation, and then differentiating the resulting smooth function to obtain the desired approximate values for the derivative at the data points.

The user chooses a set of data points either by selecting the example or by specifying a desired set of points. For the latter, select Choose Points, then click on the graph to specify the location of each point, and then finally Apply. At least two points are required to define the approximating functions. To prevent points from being too close to each other, no new point can be selected within the shaded buffer zone around each existing point.

After the points have been specified, the selected approximating function is drawn. Short line segments drawn in red through each data point indicate the derivative (slope) obtained by differentiating the approximating function at the corresponding points. The numerical values of these estimates for the derivative at each of the data points are also listed in the table. After the function is drawn, another point can be added by selecting Add Point and then clicking on the graph at the desired location, whereupon the new approximating function and resulting derivatives are drawn.

Some of the approximating functions available fit the given data points in a least squares sense, while others are interpolants that fit the data exactly. For the least squares polynomial, the user chooses the degree of the approximating polynomial. The maximum allowed degree produces the unique polynomial interpolant for the data points. Other choices of interpolating functions are the natural cubic spline and the Hermite cubic interpolant, which is montonic on each subinterval in which the data are montonic.

Reference: Michael T. Heath, Scientific Computing, An Introductory Survey, 2nd edition, McGraw-Hill, New York, 2002. See Section 8.6; the example is given in Computer Problem 8.18 on page 381.

Developers: Evan VanderZee and Michael Heath