Chapter 7

advertisement
Chapter 7
Numerical Differentiation:1*
Lecture (II)
Ref: “Applied Numerical Methods with MATLAB for Engineers and
Scientists”, Steven Chapra, 2nd ed., Ch. 19, McGraw Hill, 2008.
1*
Dr. Jie Zou PHY 3320
1
Outline

Numerical differentiation


(2) High-accuracy differentiation formulas
(3) Derivatives of unequally spaced data
Dr. Jie Zou PHY 3320
2
High-accuracy differentiation
formulas


High-accuracy finite-difference formulas
can be generated by including
additional terms from the Taylor series
expansion.
An example: High-accuracy forwarddifference formula for the first
derivative (see derivation on the next
slide)
Dr. Jie Zou PHY 3320
3
Derivation: High-accuracy forwarddifference formula for f’(x)
Forward Taylor
series expansion
f  x i 1   f  x i   f  x i h 
f  x i 
h 
2
2!
Solve for f’(x)
f  x i  
f  x i  
f  x i  2   2 f  x i 1   f  x i 
h
2
High-accuracy
forward-difference
formula
Dr. Jie Zou PHY 3320
 O h 
f  x i  
f  x i 1   f  x i 

h
f  x i 
2!
 
hO h
2
Substitute the forwarddifference approx. of f”(x)
 f  x i  2   4 f  x i 1   3 f  x i 
2h
 
O h
2
Accuracy improved to O(h2)
4
Forward finite-difference
formulas
Note: Two
versions
• Upper: Basic
• Lower: Highaccuracy
Dr. Jie Zou PHY 3320
5
Backward finite-difference
formulas
Note: Two
versions
• Upper: Basic
• Lower: Highaccuracy
Dr. Jie Zou PHY 3320
6
Centered finite-difference
formulas
Note: Two
versions
• Upper: Basic
• Lower: Highaccuracy
Dr. Jie Zou PHY 3320
7
Example

f(x) = -0.1x4 – 0.15x3 –
0.5x2 – 0.25x + 1.2
Dr. Jie Zou PHY 3320
Example 19.1 (Ref.):
Repeat the computation in
Example 4.4 to estimate
f’(x) at x = 0.5 with a step
size h = 0.25. Employ the
high-accuracy formulas for
the forward, centered, and
backward-difference
approximations.
8
Results (Example 19.1)
True value: f’(0.5) = -0.9125
HighAccuracy
formulas
Basic
formulas
h=0.25
Backward
O(h2)
Estimate
|t|
-0.878125 -0.9125
3.77%
0%
-0.859375
5.82%
h=0.25
Backward
O(h)
-0.714
21.7%
Forward
O(h)
-1.155
26.5%
Estimate
|t|
Dr. Jie Zou PHY 3320
Centered
O(h4)
Centered
O(h2)
-0.934
2.4%
Forward
O(h2)
9
Derivatives of unequally
spaced data


Experimental data are often measured at
unequal intervals. Previous formulas can be
used only for equally spaced data.
How to deal with unequally spaced data?

One method:


(i) Fit a Lagrange Interpolating Polynomial to a set of
adjacent points that bracket the point at which the
derivative needs to be evaluated;
(ii) Differentiate the Interpolating Polynomial analytically
and evaluate the derivate at the required point.
Dr. Jie Zou PHY 3320
10
Example

Example 19.3 (Ref.): As in Fig. 19.6, a
temperature gradient can be measured down
into the soil. The heat flux at the soil-air
interface can be computed with Fourier’s law:
qz  0    k

Dr. Jie Zou PHY 3320
dT
dz
z0
where q(x) = heat flux (W/m2), k = coefficient
of thermal conductivity for soil [=0.5 W/(m·K)],
T = temperature (K), and z = distance
measured down from the surface into the soil
(m). Note that a positive value of the flux
means that heat is transferred from the air to
the soil. Use numerical differentiation to
evaluate the gradient at the soil-air interface
and employ this estimate to determine the heat
flux into the ground
Answer: f’(0) = -133.333 K/m and q(z = 0) =
66.667 W/m2.
11
Download