next up previous
Next: Centered First Derivatives Up: Numerical Differentiation Previous: Numerical Differentiation

Forward and Backward First Derivatives

Suppose that we are given an array of values tex2html_wrap_inline195 , where i=0,1,2,...,N. We assume that there exists a continuous function underlying the N+1 values. Further, we assume that the underlying function has as many derivatives defined as is necessary for our purposes below. We also assume that there are N+1 values of a variable x, tex2html_wrap_inline203 . For simplicity we will take the tex2html_wrap_inline203 to be uniformly distributed in values with tex2html_wrap_inline207 and the separation of tex2html_wrap_inline203 and tex2html_wrap_inline211 independent of i, so tex2html_wrap_inline215 for all i. Having the tex2html_wrap_inline195 non-uniformly distributed would complicate the considerations which follow.

The problem is then to find approximate expressions for the first derivative using only the provided data tex2html_wrap_inline221 .

Given our assumption that there is an underlying continuous function with as many derivatives as needed, we make use of the familiar Taylor series expansion formula, which expresses the function f as an infinite series expansion about a given point of interest:


Let's evaluate f at tex2html_wrap_inline227 using the Taylor series. Simplifying slightly we find:


Now if we let tex2html_wrap_inline229 be tex2html_wrap_inline203 , then tex2html_wrap_inline233 corresponds to tex2html_wrap_inline235 and the Taylor series expansion becomes that for tex2html_wrap_inline237 . Note that if we subtract tex2html_wrap_inline195 from Eq.(2) for the i+1 case, we have


Dividing by dx and solving for the first derivative at tex2html_wrap_inline203 we obtain the forward difference approximation for the first derivative:


Note that the error in this approximation is of order tex2html_wrap_inline247 in the separation between points. Such an dependence is said to indicate that the forward difference approximation is only "first order accurate". As we will see below, one can do better than this.

Next, we give the result of performing the calculation as above except using tex2html_wrap_inline249 and tex2html_wrap_inline195 . Then, taking the difference between tex2html_wrap_inline249 and fi from the Taylor series expression and simplifying a bit, we find the backward difference approximation for the first derivative:


As is clear from inspecting this result, the backward difference approximation is also only first order accurate in dx.

Before we proceed to find more accurate approximations, let's pause to make a comment on these two formulae. From the perspective of order of accuracy, the forward and backward difference formulae represent the simplest and least accurate approximations that one can imagine. In practice these formulae are not used except in situations where a quick estimate of the derivative is needed. In most applications in computational physics, the resulting low accuracy that these formulae present make them just not good enough for serious simulation. While the two formulae are not widely used and thus will not get much attention from us in future discussions, here is a good place to point out another aspect of them which may need attention when we get some higher order accurate approximations: their one-sidedness. To illustrate the point, we can simply note that if we used the forward difference formula we would run into trouble when we try to use it on the last point i=N. There is no point and function value at i=N+1. So we can not compute the derivative at the rightmost point. However, we could get a first order accurate estimate there if we used the backward difference approximation just for that last point, since it uses values of the function at i and i-1. A similar remark can be made about the leftmost point tex2html_wrap_inline229 . At i=0 we can not use the backward formula but could use the forward formula. Hence, to the same order of accuracy in dx if we utilize both formulae we can find the derivative at all points tex2html_wrap_inline273 .

In addition, let's note that the forward and backward difference approximations would be exact if the underlying function f(x) happened to be a linear function f(x) = a + b x. However, in applications one does not know the underlying function and thus can not determine, in advance, whether these forward and backward formulae are the only ones needed. In most situation, they certainly do not suffice to capture enough about the rate of change of the data to be very useful.

next up previous
Next: Centered First Derivatives Up: Numerical Differentiation Previous: Numerical Differentiation

G. Comer Duncan
Thu Sep 10 15:19:38 EDT 1998