Estimating First Derivatives Numerically

Missing figure

We are interested in estimating the derivative of a function f at a point x. Geometrically, the derivative is the slope of the tangent to the curve y = f(x) at the point (x, f(x)) as shown in the figure above.

Suppose that we know the values of the function at the points x - h, x, and x + h. These values are indicated by dots in the figure above. We want to estimate the slope of the tangent on the basis of our knowledge about these three points.

One estimate is based on the figure below. We compute the slope of the secant line through the points (x, f(x)) and (x + h, f(x + h)). This line is shown in red in the figure below. If h is relatively small then this gives us a relatively good estimate for the slope of the tangent.

Missing figure

The slope of this secant is

Missing figure

A better estimate is based on the figure below. Now we compute the slope of the secant line through the two points (x - h, f(x - h)) and (x + h, f(x + h)). This line is shown in red in the figure below.

Missing figure

The slope of this secant is

Missing figure

Comparing the two pictures you can see that the second estimate is much better than the first estimate.

This gives us the estimate

Missing equation

The same idea enables us to estimate partial derivatives.

Missing equation


Copyright c 1997 by Frank Wattenberg, Department of Mathematics, Montana State University, Bozeman, MT 59717