Post on 23-Mar-2016
description
CISE301_Topic6 1
SE301: Numerical Methods
Topic 6 Numerical Differentiation
Lecture 23
KFUPM
Read Chapter 23, Sections 1-2
CISE301_Topic6 2
Lecture 23Numerical
Differentiation
First order derivatives High order derivatives Richardson Extrapolation Examples
CISE301_Topic6 3
Motivation How do you evaluate the
derivative of a tabulated function.
How do we determine the velocity and acceleration from tabulated measurements.
Time(second)
Displacement(meters)
0 30.1
5 48.2
10 50.0
15 40.2
CISE301_Topic6 4
Recall
nn
nn
h
hEh
hCEthatsuchCfiniterealhOE
hOhxfhxfhxfxfhxf
hxfhxf
dxdf
similar to rateat zero gapproachin isorder of is E
:,, )(
)(!3
)(!2)()(')()(
:TheoremTaylor
)()(lim
43)3(2)2(
0
CISE301_Topic6 5
Three Formula
them?judge wedo How better? is methodWhich
2)()()(:DifferenceCentral
)()()(:DifferenceBackward
)()()(:DifferenceForward
hhxfhxf
dxxdf
hhxfxf
dxxdf
hxfhxf
dxxdf
CISE301_Topic6 6
The Three Formulas
CISE301_Topic6 7
Forward/Backward Difference Formula
)()()()('
)()()()('
)()(')()( :DifferenceBackward
_______________________________________________________
)()()()('
)()()()('
)()(')()(:DifferenceForward
2
2
2
2
hOh
hxfxfxf
hOhxfxfhxf
hOhxfxfhxf
hOh
xfhxfxf
hOxfhxfhxf
hOhxfxfhxf
CISE301_Topic6 8
Central Difference Formula
)(2
)()()('
...!3
)(2)('2)()(
...!4)(
!3)(
!2)()(')()(
...!4)(
!3)(
!2)()(')()(
:DifferenceCentral
2
3)3(
4)4(3)3(2)2(
4)4(3)3(2)2(
hOh
hxfhxfxf
hxfhxfhxfhxf
hxfhxfhxfhxfxfhxf
hxfhxfhxfhxfxfhxf
CISE301_Topic6 9
The Three Formula (Revisited)
answer.better a give toexpected is formula difference Centralaccuracy.in comparable are formulas difference backward andForward
)(2
)()()(:DifferenceCentral
)()()()(:DifferenceBackward
)()()()(:DifferenceForward
2hOh
hxfhxfdxxdf
hOh
hxfxfdxxdf
hOh
xfhxfdxxdf
CISE301_Topic6 10
Higher Order Formulas
12)(
)()()(2)()(
...!4
)(2!2
)(2)(2)()(
...!4
)(!3
)(!2
)()(')()(
...!4
)(!3
)(!2
)()(')()(
2)4(
22
)2(
4)4(2)2(
4)4(3)3(2)2(
4)4(3)3(2)2(
hfError
hOh
hxfxfhxfxf
hxfhxfxfhxfhxf
hxfhxfhxfhxfxfhxf
hxfhxfhxfhxfxfhxf
CISE301_Topic6 11
Other Higher Order Formulas
.ordererror theobtainand themprove toTheoremTaylor use can Youpossible. also are)...(),(for formulasOther
)( with FormulasCentral
)2()(4)(6)(4)2()(
2)2()(2)(2)2()(
)()(2)()(
)3()2(
2
4)4(
3)3(
2)2(
xfxf
hOError
hhxfhxfxfhxfhxfxf
hhxfhxfhxfhxfxf
hhxfxfhxfxf
Example Use forward, backward and centered difference
approximations to estimate the first derivate of:f(x) = –0.1x4 – 0.15x3 – 0.5x2 – 0.25x + 1.2at x = 0.5 using step size h = 0.5 and h = 0.25
Note that the derivate can be obtained directly:f’(x) = –0.4x3 – 0.45x2 – 1.0x – 0.25The true value of f’(0.5) = -0.9125
In this example, the function and its derivate are known. However, in general, only tabulated data might be given.
CISE301_Topic6 12
Solution with Step Size = 0.5 f(0.5) = 0.925, f(0) = 1.2, f(1.0) = 0.2 Forward Divided Difference:
f’(0.5) (0.2 – 0.925)/0.5 = -1.45|t| = |(-0.9125+1.45)/-0.9125| = 58.9%
Backward Divided Difference: f’(0.5) (0.925 – 1.2)/0.5 = -0.55|t| = |(-0.9125+0.55)/-0.9125| = 39.7%
Centered Divided Difference: f’(0.5) (0.2 – 1.2)/1.0 = -1.0|t| = |(-0.9125+1.0)/-0.9125| = 9.6%
CISE301_Topic6 13
Solution with Step Size = 0.25 f(0.5)=0.925, f(0.25)=1.1035, f(0.75)=0.6363 Forward Divided Difference:
f’(0.5) (0.6363 – 0.925)/0.25 = -1.155|t| = |(-0.9125+1.155)/-0.9125| = 26.5%
Backward Divided Difference: f’(0.5) (0.925 – 1.1035)/0.25 = -0.714|t| = |(-0.9125+0.714)/-0.9125| = 21.7%
Centered Divided Difference: f’(0.5) (0.6363 – 1.1035)/0.5 = -0.934|t| = |(-0.9125+0.934)/-0.9125| = 2.4%
CISE301_Topic6 14
Discussion For both the Forward and Backward difference,
the error is O(h) Halving the step size h approximately halves the
error of the Forward and Backward differences The Centered difference approximation is more
accurate than the Forward and Backward differences because the error is O(h2)
Halving the step size h approximately quarters the error of the Centered difference.
CISE301_Topic6 15
CISE301_Topic6 16
Richardson Extrapolation
...)(')(2
)()()(
:)(
formula?better aget Can we
)(2
)()()(':DifferenceCentral
66
44
22
2
hahahaxfhh
hxfhxfh
fixedxandxfHold
hOh
hxfhxfxf
CISE301_Topic6 17
Richardson Extrapolation
)()(31)2/(
34)('
...1615
43)('3)
2(4)(
...222
)(')2
(
...)(')(2
)()()(
:)(
4
66
44
6
6
4
4
2
2
66
44
22
hOhhxf
hahaxfhh
hahahaxfh
hahahaxfhh
hxfhxfh
fixedxandxfHold
Use two derivate estimates to compute a third, more accurate approximation
Richardson Extrapolation Example Use the function:
f(x) = –0.1x4 – 0.15x3 – 0.5x2 – 0.25x + 1.2
Starting with h1 = 0.5 and h2 = 0.25, compute an improved estimate of f’(0.5) using Richardson Extrapolation
Recall the true value of f’(0.5) = -0.9125
CISE301_Topic6 18
Solution The first-derivative estimates can be computed
with centered differences as:
CISE301_Topic6 19
example for thisresult exact theproduces Which
9125.0)1(31)934375.0(
34)(
31)2/(
34)5.0('
:applyingby obtained be can estimate improved The
%4.2 || ,934375.05.0
)25.0()75.0()25.0(
%6.9 || ,0.11
2.12.01
)0()1()5.0(
5.0at 2
)5.0()5.0()(
hhf
ff
ff
xh
hfhfh
t
t
CISE301_Topic6 20
Richardson Extrapolation Table
D(0,0)=Φ(h)
D(1,0)=Φ(h/2) D(1,1)
D(2,0)=Φ(h/4) D(2,1) D(2,2)
D(3,0)=Φ(h/8) D(3,1) D(3,2) D(3,3)
CISE301_Topic6 21
Richardson Extrapolation Table
)1,1(14
1)1,(14
4),(
:
2)0,( :
mnDmnDmnD
Others
hnDColumnFirst
mm
m
n
CISE301_Topic6 22
Example
. derivative theof estimate theas D(2,2)Obtain
10 ion with Extrapolat Richardson Use
60at
:of derivative y thenumericall Evaluatecos
.h
.xxf(x) (x)
CISE301_Topic6 23
ExampleFirst Column
1.091150.05
f(0.575)-)625.f(0(0.025)
1.089880.1
f(0.55)-)65.f(0(0.05)
1.084830.2
f(0.5)-7).f(0(0.1)
2hh)-f(x-h)f(x(h)
CISE301_Topic6 24
ExampleRichardson Table
1.09157)11(151)12(
1516)22(
1.09157)01(31)02(
34)12(
1.09156)00(31)01(
34)1,1(
)1,1(14
1)1,(14
4),(
09115.1 D(2,0)1.08988, D(1,0), 08483.1)0,0(
,D,D,D
,D,D,D
,D,DD
mnDmnDmnD
D
mm
m
CISE301_Topic6 25
ExampleRichardson Table
1.08483
1.08988 1.091561.09115 1.09157 1.09157
This is the best estimate of the derivative of the function.
All entries of the Richardson table are estimates of the derivative of the function.
The first column are estimates using the central difference formula with different step size h.