CHAP 23e
CHAP 23e
Numerical Differentiation
Chapter 23
1
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
High Accuracy Differentiation Formulas
• High-accuracy divided-difference formulas can be generated by including additional
terms from the Taylor series expansion.
• Inclusion of the 2nd derivative term has improved the accuracy to O(h2).
• Similar improved versions can be developed for the backward and centered formulas
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Forward finite-divided-difference formulas
Error
O(h)
O(h2)
Error
O(h)
O(h2)
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Backward finite-divided-difference formulas
Error
O(h)
O(h2)
Error
O(h)
O(h2)
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Centered finite-divided-difference formulas
Error
O(h2)
O(h4)
Error
O(h2)
O(h4)
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Derivation of the centered formula for f’’(xi)
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Differentiation Using MATLAB
x f(x) First, create a file called fx1.m which contains y=f(x):
i-2 0 1.2 function y = fx1(x)
i-1 0.25 1.1035 y = 1.2 - .25*x - .5*x.^2 - .15*x.^3 -.1*x.^4 ;
i 0.50 0.925
i+1 0.75 0.6363 Command window:
i+2 1 0.2 >> x=0:.25:1
0 0.25 0.5 0.75 1
>> y = fx1(x)
8
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Richardson Extrapolation
• There are two ways to improve derivative estimates when employing finite divided
differences:
– Decrease the step size, or
– Use a higher-order formula that employs more points.
• A third approach, based on Richardson extrapolation, uses two derivative estimates
(with O(h2) error) to compute a third (with O(h4) error) , more accurate approximation.
We can derive this formula following the same steps used in the case of the integrals:
Example: using the previous example and Richardson’s formula, estimate the first
derivative at x=0.5 Using Centered Difference approx. (with error O(h2)) with
h=0.5 and h=0.25 :
• Data from experiments or field studies are often collected at unequal intervals.
• Fit a Lagrange interpolating polynomial, and then calculate the 1st derivative.
*Note that any three points, xi-1 xi and xi+1 can be used to calculate the derivative. The
points do not need to be spaced equally.
10
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Example:
The heat flux at the soil-air interface can be computed with Fourier’s Law:
q = heat flux
k = coefficient of thermal diffusivity in soil (≈3.5x10 -7 m2/s)
ρ = soil density(≈ 1800 kg/m3)
C = soil specific heat(≈ 840 J/kg . C o)
*Positive flux value means heat is transferred from the air to the soil
Calculate dT/dz (z=0) first and then and determine the heat flux.
A temperature gradient can be measured down into the soil as shown below.
MEASUREMENTS