Download - Lecture on Numerical Differentiation
-
8/6/2019 Lecture on Numerical Differentiation
1/102
6/3/2011 1
Differentiation-Continuous
Functions
-
8/6/2019 Lecture on Numerical Differentiation
2/102
2
Forward Difference Approximation
x
xfxxf
x
xf
0
lim
p
!d
For a finite '' x
x
xfxxfxf(
(}d
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
3/102
3
x x+x
f(x)
Figure 1 Graphical Representation of forward difference approximation of first derivative.
Graphical Representation OfForward Difference
Approximation
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
4/102
-
8/6/2019 Lecture on Numerical Differentiation
5/102
5
Example 1 Cont.
Solution
t
ttta iii
(
}
RR 1
16!it
2 !t
18
2161
!
!(! ttt ii
2
161816
RR }a
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
6/102
6
Example 1 Cont.
188.91821001014
1014ln200018
4
4
v
v!R
m/s02.453!
168.91621001014
1014ln200016
4
4
v
v!R
m/s07.392!
Hence
2
161816
RR }a
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
7/102
7
Example 1 Cont.
2
07.39202.453 }
2m/s474.30}
The exact value of 16a can be calculated by differentiating
tt
t 8.921001014
1014ln2000
4
4
v
v!R
as
? Atdt
dta !
b)
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
8/102
8
Example 1 Cont.
Knowing that
? At
t
dt
d 1ln ! and 2
11
ttdt
d!
8.921001014
1014
1014
210010142000
4
4
4
4
v
v
v
v!
tdt
dtta
8.9210021001014
101411014
21001014200024
4
4
4
vv
vv!
t
t
t
t
3200
4.294040
!
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
9/102
9
Example 1 Cont.
163200164.294040
16
!a
2
m/s674.29!
The absolute relative true error is
100
ValueTrue
ValueeApproximat-ValueTruext !
100674.29
474.30674.29x
!
%6967.2!6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
10/102
10
Backward Difference Approximation of the
First Derivative
We know
x
xfxxf
xxf
0
lim
p
!d
For a finite '' x ,
x
xfxxfxf
(
(}d
If '' x is chosen as a negative number,
x
xfxxfxf
(
(}d
x
xxfxf
!
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
11/102
11
Backward Difference Approximation of the
First Derivative Cont.
This is a backward difference approximation as you are taking a point backward from x. To find the value of xfd at ixx ! , we may choose anotherpoint '' x behind as
1
!i
xx . This gives
x
xfxfxf iii
(
}d 1
1
1
!
ii
ii
xx
xfxf
where
1 ! ii xxx
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
12/102
12
xx-x
x
f(x)
Figure 2 Graphical Representation of backward differenceapproximation of first derivative
Backward Difference Approximation of the
First Derivative Cont.
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
13/102
13
Example 2
The velocity of a rocket is given by
300,8.9210010141014
ln2000 4
4
ee
v
v
! ttttR
where '' is given in m/s and ''t is given in seconds.
a) Use backward difference approximation of the first derivative ofto calculate the acceleration at . Use a step size of .
b) Find the absolute relative true error for part (a).
ts16!t st 2 !
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
14/102
14
Example 2 Cont.Solution
t
ttta ii
(
} 1
RR
16!it
2 !t
14216
1
!
!(! ttt ii
2
141616
RR }a
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
15/102
15
Example 2 Cont.
168.91621001014
1014ln200016
4
4
v
v!R
m/s07.392!
148.91421001014
1014ln200014
4
4
v
v!R
m/s24.334!
2
141616
RR }a
2
24.33407.392 !
2
m/s915.28}6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
16/102
16
Example 2 Cont.
The absolute relative true error is
100674.29
915.28674.29xt
!
%5584.2!
The exact value of the acceleration at from Example 1 is
2m/s674.2916 !a
s16!t
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
17/102
17
Derive the forward difference approximation
from Taylor series
Taylors theorem says that if you know the value of a function '' f at a point
ix and all its derivatives at that point, provided the derivatives are
continuous between ix and 1ix , then
-dd
d! 2
111!2
iii
iiiii xxxf
xxxfxfxf
Substituting for convenienceii xxx ! 1
-ddd!2
1 !2
xxfxxfxfxf iiii
-(dd
(
!d x
xf
x
xfxfxf iiii
!2
1
xx
xfxfxf iii (
(
!d 01
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
18/102
18
Derive the forward difference approximation
from Taylor series Cont.
The x(0 term shows that the error in the approximation is of the order
of x Can you now derive from Taylor series the formula for backward
divided difference approximation of the first derivative?
As shown above, both forward and backward divided difference
approximation of the first derivative are accurate on the order of x(0
Can we get better approximations? Yes, another method to approximate
the first derivative is called the Central difference approximationof
the first derivative.
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
19/102
19
Derive the forward difference approximation
from Taylor series Cont.
From Taylor series
-ddd
dd
d!32
1 !3
!2
xxf
xxf
xxfxfxf iiiii
-ddd
dd
d!32
1 !3
!2
xxf
xxf
xxfxfxf iiiii
Subtracting equation (2) from equation (1)
-ddd
d! 3
11 !3
22 xxfxxfxfxf iiii
-(ddd
(
!d
211
!32x
xf
x
xfxfxf iiii
211 0
2
x
x
xfxfxf iii (
(
!d
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
20/102
20
Central Divided Difference
Hence showing that we have obtained a more accurate formula as the
error is of the order of . 20 x
x
f(x)
x-x x x+x
Figure 3 Graphical Representation of central difference approximation offirst derivative6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
21/102
21
Example 3
The velocity of a rocket is given by
300,8.9210010141014
ln2000 4
4
ee
v
v!
ttttR
where '' is given in m/s and ''t is given in seconds.
(a) Use central divided difference approximation of the first derivative ofto calculate the acceleration at . Use a step size of .
(b) Find the absolute relative true error for part (a).
tst 16! st 2 !
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
22/102
22
Example 3 cont.
Solution
t
ttta iii
(
}
2
11 RR
16!it
18216
1
!!
(! ttt ii
142161
!!(! ttt
ii
221418
16RR
}a
4
1418 RR }
2!(t
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
23/102
23
Example 3 cont.
188.91821001014
1014ln200018
4
4
v
v!R
m/s02.453!
148.91421001014
1014ln200014
4
4
v
v!R
m/s24.334!
4
141816 RR }a
4
24.33402.453 }
2m/s694.29}6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
24/102
24
Example 3 cont.
The absolute relative true error is
100674.29
694.29674.29v
!t
%069157.0!
The exact value of the acceleration at from Example 1 is
2m/s674.2916 !as16!t
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
25/102
25
Comparision of FDD, BDD, CDD
The results from the three difference approximations are given in Table 1.
Type of Difference
Approximation
ForwardBackward
Central
30.47528.915
29.695
2.69672.5584
0.069157
Table 1 Summary of a (16) using different divided difference approximations
16a
2/sm%t
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
26/102
26
Finding the value of the derivative
within a prespecified tolerance
In real life, one would not know the exact value of the derivative so how
would one know how accurately they have found the value of the derivative.
A simple way would be to start with a step size and keep on halving the step
size and keep on halving the step size until the absolute relative approximate
error is within a pre-specified tolerance.
Take the example of finding for tvd t
tt 8.9
21001014
1014ln2000
4
4
v
v!R
at using the backward divided difference scheme.16!t6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
27/102
2
1
0.5
0.25
0.125
28.91529.289
29.480
29.577
29.625
1.2792
0.64787
0.32604
0.16355
27
Finding the value of the derivative
within a prespecified tolerance Cont.
Given in Table 2 are the values obtained using the backward differenceapproximation method and the corresponding absolute relativeapproximate errors.
t( tvd %a
Table 2 First derivative approximations and relative errors fordifferentt values of backward difference scheme
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
28/102
28
Finding the value of the derivative
within a prespecified tolerance Cont.
From the above table, one can see that the absolute relative
approximate error decreases as the step size is reduced. At 125.0!(t
the absolute relative approximate error is0.16355%
, meaning thatat least2 significant digits are correct in the answer.
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
29/102
29
Finite Difference Approximation of
Higher Derivatives
One can use Taylor series to approximate a higher order derivative.
For example, to approximate xfdd , the Taylor series for
-ddd
dd
d!32
2 2!3
2!2
2 xxf
xxf
xxfxfxf iiiii
where
xxx ii 22 !
-321!3!2
xxf
xxf
xxfxfxf iiiii (ddd(dd(d!
where
xxx ii 1 !6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
30/102
30
Finite Difference Approximation of
Higher Derivatives Cont.
Subtracting 2 times equation (4) from equation (3) gives
-3212 2 xxfxxfxfxfxf iiiii ddddd!
-ddd
!dd xxf
x
xfxfxfxf i
iii
i
22
12
x
x
xfxfxfxf iiii 0
22
12
$dd (5)
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
31/102
31
Example 4
The velocity of a rocket is given by
300,8.9210010141014
ln2000 4
4
ee
v
v
! ttttR
Use forward difference approximation of the second derivative
of to calculate the jerk at . Use a step size of .
tst 16! st 2 !
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
32/102
-
8/6/2019 Lecture on Numerical Differentiation
33/102
33
Example 4 Cont.
208.92021001014
1014ln200020
4
4
v
v!R
m/s35.517!
188.91821001014
1014ln200018
4
4
v
v!R
s/02.453!
168.91621001014
1014ln200016
4
4
v
v!R
m/s07.392!6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
34/102
34
Example 4 Cont.
4
07.39202.453235.51716
}j
3m/s84515.0}
The exact value of 16j can be calculated by differentiating
tt
t 8.921001014
1014ln2000
4
4
v
v!R
twice as
? Atdt
dta ! and ? Ata
dt
dtj !
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
35/102
35
Example 4 Cont.
Knowing that
? At
t
dt
d 1ln ! and
2
11
ttdt
d!
8.921001014
1014
1014
210010142000
4
4
4
4
v
v
v
v!
tdt
dtta
t
t
3200
4.294040
!
8.92100210010141014
11014
210010142000 24
4
4
4
v
v
v
v
! t
t
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
36/102
36
Example 4 Cont.
? A
2)3200(
18000t
tadt
dtj
!
!
3
2
m/s77909.0
)]16(3200[
1800016
!
!j
The absolute relative true error is
10077909.0
84515.077909.0v
!t
%4797.8!
Similarly it can be shown that
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
37/102
37
Higher order accuracy of higher
order derivatives
The formula given by equation (5) is a forward difference approximation of
the second derivative and has the error of the order of x . Can we get
a formula that has a better accuracy? We can get the central difference
approximation of the second derivative.
The Taylor series for
-4321!4!3!2
xxf
xxf
xxf
xxfxfxf iiiiii (dddd
(ddd
(dd
(d!
where
xxx ii 1 !
(6)
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
38/102
38
Higher order accuracy of higher
order derivatives Cont.
-4321!4!3!2
xxf
xxf
xxf
xxfxfxf iiiiii (dddd
(ddd
(dd
(d!
where
xxx ii 1 !
(7)
Adding equations (6) and (7), gives
12
2
42
11
xxfxxfxfxfxf iiiii ddddd!
12
22
2
11 xxf
x
xfxfxfxf iiiii
dddd
!dd
22
11 0
2x
x
xfxfxfxf iiii
!dd
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
39/102
39
Example 5
The velocity of a rocket is given by
300,8.921001014
1014ln2000
4
4
ee
v
v! tt
ttR
Use central difference approximation of second derivative of tocalculate the jerk at . Use a step size of .
tst 16! st 2 !
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
40/102
-
8/6/2019 Lecture on Numerical Differentiation
41/102
41
Example 5 Cont.
188.91821001014
1014ln200018
4
4
v
v!R
m/s02.453!
168.91621001014
1014ln200016
4
4
v
v!R
m/s07.392!
148.91421001014
1014ln200014
4
4
v
v!R
m/s24.334!
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
42/102
42
Example 5 Cont.
221416218
16RRR
}j
424.33407.392202.453
}
The absolute relative true error is
10077908.0
78.077908.0 v!t
3m/s77969.0}
%077992.0!
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
43/102
-
8/6/2019 Lecture on Numerical Differentiation
44/102
44
Forward Difference Approximation
x
xfxxf
x
xf
0
lim
p
!d
For a finite '' x
x
xfxxfxf(
(}d
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
45/102
45
x x+x
f(x)
Figure 1 Graphical Representation of forward difference approximation of first derivative.
Graphical Representation OfForward Difference
Approximation
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
46/102
46
Example 1The upward velocity of a rocket is given as a function of time inTable 1.
Using forward divided difference, find the acceleration of the
rocket at .
t v(t)
s m/s
0 0
10 227.04
15 362.78
20 517.3522.5 602.97
30 901.67
Table 1 elocity as a function of time
s16!t6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
47/102
47
Example 1 Cont.
t
ttta iii
(
}
RR 1
15!it
5
15201
!!!( ii ttt
To find the acceleration at , we need to choose thetwo values closest to , that also bracket to
evaluate it. The two points are and .
s16!ts16!t
s20!ts15!t
201 !it
s16!t
Solution
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
48/102
48
Example 1 Cont.
2m/s914.30
5
78.36235.5175
152016
}
}
}
RRa
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
49/102
49
Direct Fit Polynomials
'1' n nn
yxyxyxyx ,,,,,,,, 221100 -
thn
nn
n
nnxaxaxaaxP !
1
110 --
12121 12)(
!!dn
n
n
n
n
nxnaxanxaa
dx
xdPxP --
In this method, given data points
one can fit a order polynomial given by
To find the first derivative,
Similarly other derivatives can be found.
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
50/102
50
Example 2-Direct Fit Polynomials
The upward velocity of a rocket is given as a function of time inTable 2.
Using the third order polynomial interpolant for velocity,find the acceleration of the rocket at .
t v(t)
s m/s
0 0
10 227.04
15 362.78
20 517.3522.5 602.97
30 901.67
Table 2 elocity as a function of time
s16!t6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
51/102
51
Example 2-Direct Fit Polynomials cont.
For the third order polynomial (also called cubic interpolation), we choose the velocity given by
332
210 tatataatv !
Since we want to find the velocity at , and we are using third order polynomial, we needto choose the four points closest to and that also bracket to evaluate it.
The four points are
04.227,10 !! oo tvt
78.362,15 11 !! tvt
35.517,20 22 !! tvt
97.602,5.22 33 !! tvt
Solution
s16!ts16!t s16!t
.5.22and,20,15,10 321 !!!! tttto
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
52/102
52
Example 2-Direct Fit Polynomials cont.
such that
Writing the four equations in matrix form, we have
332
210 10101004.22710 aaaav !!
33
2
210
15151578.36215 aaaav !!
332
210 20202035.51720 aaaav !!
332
210 5.225.225.2297.6025.22 aaaav !!
!
97.602
35.517
78.362
04.227
1139125.5065.221
8000400201
3375225151
1000100101
3
2
1
0
a
a
a
a
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
53/102
53
Example 2-Direct Fit Polynomials cont.
Solving the above four equations gives
3810.40 !a
289.211 !a
13065.02 !a
0054606.03 !aHence
5.2210,0054606.013065.0289.213810.4 32
3
3
2
210
ee!
!
tttt
tatataatv
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
54/102
54
Example 2-Direct Fit Polynomials cont.
Figure 1 Graph of upward velocity of the rocket vs. time.6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
55/102
-
8/6/2019 Lecture on Numerical Differentiation
56/102
56
Lagrange Polynomial
nn
yxyx ,,,, 11 - th
n 1In this method, given , one can fit a order Lagrangian polynomialgiven by
!
!n
i
iin xfxLxf0
)()()(
where n in )(xfn stands for the thn order polynomial that approximates the function
)(xfy ! given at )1( n data points as nnnn yxyxyxyx ,,,,......,,,, 111100 , and
{!
!
n
ijj ji
j
i
xx
xxx
0
)(
)(xi a weighting function that includes a product of )1( n terms with terms of
ij ! omitted.
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
57/102
57
Then to find the first derivative, one can differentiate xfn
for other derivatives.
For example, the second order Lagrange polynomial passing through
221100 ,,,,, yxyxyx is
21202
10
12101
20
02010
21
2
xfxxxx
xxxxxf
xxxx
xxxxxf
xxxx
xxxxxf
!
Differentiating equation (2) gives
once, and so on
Lagrange Polynomial Cont.
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
58/102
58
21202
1
2101
0
2010
2
222xf
xxxxxf
xxxxxf
xxxxxf
!dd
2
1202
101
2101
200
2010
212
222xf
xxxx
xxxxf
xxxx
xxxxf
xxxx
xxxxf
!
d
Differentiating again would give the second derivative as
Lagrange Polynomial Cont.
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
59/102
59
Example 3
Determine the value of the acceleration at usingthe second order Lagrangian polynomial interpolation for
velocity.
t v(t)
s m/s
0 0
10 227.04
15 362.78
20 517.3522.5 602.97
30 901.67
Table 3 elocity as a function of time
s16!t
The upward velocity of a rocket is given as a function of time inTable 3.
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
60/102
60
Solution
Example 3 Cont.
)()()()( 212
1
02
0
1
21
2
01
0
0
20
2
10
1 tvtt
tt
tt
tttv
tt
tt
tt
tttv
tt
tt
tt
tttv
!
0
2010
212 ttttt
tttta R
!
12101
202 ttttt
tttR
2
1202
102 ttttt
ttt
04.22720101510
201516216
!a
78.36220151015
2010162
35.517
15201020
1510162
35.51714.078.36208.004.22706.0 !
2m/s784.29!
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
61/102
Backward DividedDifference
6/3/2011 61
-
8/6/2019 Lecture on Numerical Differentiation
62/102
62
Definition
ix
ix
.
x
xxfxf
x
xf
(
(
p(!d
0
lim
Slope at
f(x)
y
x
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
63/102
63
Backward Divided Difference
xx (xx
x
xxfxfxf
(
($d
x
xxfxfxf iii
(
($d
)(xf
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
64/102
64
Example
Example:
The velocity of a rocket is given by
300,8.9210010141014
ln2000 4
4
ee
v
v
! ttttR
whereR given in m/s and t is given in seconds. Use backward difference approximation
Of the first derivative of t to calculate the acceleration at .16st! Use a step size of.2st!(
t
ttta iii
(
$ 1
RRSolution:
16!it6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
65/102
65
2 !t
ttt ii (!1 14216 !!
2
141616
RR !a
168.91621001014
1014ln200016
4
4
v
v!R s/07.392!
148.91421001014
1014ln200014
4
4
v
v!R s/24.334!
Example (contd.)
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
66/102
66
Hence
The exact value of 16a can be calculated by differentiating
tt
t 8.921001014
1014ln2000
4
4
v
v!R
as
Example (contd.)
2/915.2824.33407.3922
)14()16(16 sma !!
!
RR
? A
2/674.29)16(
3200
4.294040)()(
sa
t
tt
dt
dta
!
!! R
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
67/102
67
The absolute relative true error is
Example (contd.)
100v
!TrueValue
eValueApproximatTrueValuetI
%557.2
100674.29
915.28674.29
!
v
!
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
68/102
68
Effect Of Step Size
xexf 49)( !
Value of )2.0('f Using backward Divided difference method.
h )2.0('
f aE aI % S g f digits
tE
tI %
0.05 72.61598 7.50 49 9. 65 77
0.025 76.24 76 .627777 4.758129 1 .87571 4.8 7418
0.0125 78.14946 1.905697 2.4 8529 1 1.97002 2.458849
0.00625 79.12627 0.976817 1.2 4504 1 0.99 20 1.2 9648
0.00 125 79.62081 0.4945 0.62111 1 0.49867 0.622404
0.00156 79.86962 0.248814 0. 11525 2 0.24985 0. 1185
0.000781 79.99442 0.124796 0.156006 2 0.12506 0.156087
0.000 91 80.05691 0.062496 0.078064 2 0.06256 0.078084
0.000195 80.08818 0.0 1272 0.0 9047 0.0 129 0.0 9052
9.77E-05 80.10 8 0.015642 0.019527 0.01565 0.019529
4.88E-05 80.11165 0.00782 0.009765 0.00782 0.0097656/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
69/102
69
Effect of Step Size in Backward
Divided Difference Method
8
9
1 3 9 11
Number of times the step size is halved, n
f'(0.
2
Initial step size=0.05
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
70/102
70
Effect of Step Size on Approximate
Error
0
4
5 7
Number of steps involved, n
Ea
Initial step size=0.05
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
71/102
Effect of Step Size on Least
-
8/6/2019 Lecture on Numerical Differentiation
72/102
72
Effect of Step Size on Least
Number of Significant Digits
Correct
2
2.
.
2 7
Number of steps involved, n
Least
numberofsignif
ican
digitscorrect
Initial step size=0.05
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
73/102
73
Effect of Step Size on True Error
2
3
7
2 6 2
Number of steps involved, n
Et
Initial step size=0.05
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
74/102
-
8/6/2019 Lecture on Numerical Differentiation
75/102
6/3/2011 75
Central Divided Difference
-
8/6/2019 Lecture on Numerical Differentiation
76/102
76
Definition
ix
.
x
xxfxf
x
xf(
(
p(!d
0
lim
f(x)
Slope at
x
y
ix6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
77/102
-
8/6/2019 Lecture on Numerical Differentiation
78/102
78
Example
Example:
The velocity of a rocket is given by
300,8.9210010141014
ln2000 4
4
ee
v
v!
ttttR
where R given in m/s and t is given in seconds. Use central difference approximation of
the first derivative of t to calculate the acceleration at .16st! Use a step size of.2st!(
t
ttta iii
(
$
2
11 RR
Solution:
16!it6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
79/102
79
2 !t
ttt ii 1 ! 18216 !!
4
1418
)2(2
141816
RRRR !
!a
188.91821001014
1014ln2000184
4
v
v!R s/02.453!
148.91421001014
1014ln200014
4
4
v
v!R sm /24.334!
Example (contd.)
ttt ii (!1 14216 !!
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
80/102
80
Hence
The exact value of 16a can be calculated by differentiating
tt
t 8.921001014
1014ln2000
4
4
v
v!R
as
Example (contd.)
2/695.2924.33402.453
4
)14()18(16 sma !!
!
RR
? A
2/674.29)16(
3200
4.294040)()(
sa
t
tt
dt
dta
!
!! R
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
81/102
81
The absolute relative true error is
Example (contd.)
100v
!True alue
e aluepproxi atTrue aluetI
%070769.0
100674.29
695.29674.29
!
v
!
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
82/102
82
Effect Of Step Size
xexf 49)( !
Value of )2.0('f Using Central Divided Difference difference method.
h )(
f aE aI % Sig ifica tdigits
tE
tI %
0.05 80.65467 -0.5 520 0.668001
0.025 80.25 07 -0.4016 0.500417 1 -0.1 60 0.16675
0.0125 80.15286 -0.100212 0.125026 2 -0.0 9 0.041672
0.00625 80.12782 -0.025041 0.0 1252 -0.008 5 0.010417
0.00 125 80.12156 -0.00626 0.00781 -0.00209 0.0026040.00156 80.12000 -0.001565 0.00195 4 -0.00052 0.000651
0.000781 80.11960 -0.000 91 0.000488 5 -0.0001 0.00016
0.000 91 80.11951 -9.78 -05 0.000122 5 -0.0000 4.07 -05
0.000195 80.11948 -2.45 -05 .05 -05 6 -0.00001 1.02 -05
9.77 -05 80.11948 -6.11 -06 7.6 -06 6 0.00000 2.54 -06
4.88 -05 80.11947 -1.5 -06 1.91 -06 7 0.00000 6. 6 -076/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
83/102
Effect of Step Size on Approximate
-
8/6/2019 Lecture on Numerical Differentiation
84/102
84
Effect of Step Size on Approximate
Error
Number of steps involved, n
E(a)
Initial step size=0.05
6/3/2011
Effect of Step Size on Absolute
-
8/6/2019 Lecture on Numerical Differentiation
85/102
85
Effect of Step Size on Absolute
Relative Approximate Error
5
5 8
Number eps involved, n
|E(a)|,
Initial step size=0.05
6/3/2011
Effect of Step Size on Least
-
8/6/2019 Lecture on Numerical Differentiation
86/102
86
Effect of Step Size on Least
Number of Significant Digits
Correct
6
8
6 8
Number of s teps involved, n
Least
numberofsignificantdigits
correct
Initial step size=0.05
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
87/102
87
Effect of Step Size on True Error
8
Number of steps involved, n
E(t)
Initial step size=0.05
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
88/102
-
8/6/2019 Lecture on Numerical Differentiation
89/102
6/3/2011 89
Forward Divided Difference
-
8/6/2019 Lecture on Numerical Differentiation
90/102
90
Definition
ix
.
x
xfxxf
xxf
0
lim
p!d
f(x)
Slope at
x
y
ix6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
91/102
91
Forward Divided Difference
xx ( xx
x
xfxxfxf
(
($d
x
xfxxfxf iii
(
($d
)(xf
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
92/102
92
Example
Example:
The velocity of a rocket is given by
300,8.921001014
1014ln2000
4
4
ee
v
v! tt
ttR
whereR given in m/s and t is given in seconds. Use forward difference approximation of
the first derivative of t to calculate the acceleration at .16st! Use a step size of.2st!(
t
ttta iii
1 $ Solution:
16!it6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
93/102
93
2 !t
ttt ii 1 ! 18216 !!
2
161816 RR !a
188.91821001014
1014ln200018
4
4
v
v!R s/02.453!
168.91621001014
1014ln200016
4
4
vv!R s/07.392!
Example (contd.)
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
94/102
94
Hence
The exact value of 16a can be calculated by differentiating
tt
t 8.921001014
1014ln2000
4
4
v
v!R
as
Example (contd.)
2/475.3007.39202.453
2
)16()18(16 sma !!
!
RR
? A
2/674.29)16(
3200
4.294040)()(
sa
t
tt
dt
dta
!
!! R
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
95/102
95
The absolute relative true error is
Example (contd.)
100v
!TrueValue
eValueApproximatTrueValuetI
%6993.2
100674.29
475.30674.29
!
v
!
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
96/102
96
Effect Of Step Size
xexf 49)( !
Value of )2.0('f Using forward difference method.
h )(
f aE aI % Sig ifica tdigits
tE
tI %
0.05 88.69 6 -8.57 89 10.701 8
0.025 84.262 9 -4.4 0976 5.258546 0 -4.14291 5.170918
0.0125 82.15626 -2.106121 2.56 555 1 -2.0 679 2.54219
0.00625 81.129 7 -1.0269 1.265756 1 -1.00989 1.260482
0.00 125 80.622 1 -0.507052 0.62892 1 -0.50284 0.627612
0.00156 80. 70 7 -0.251944 0. 1 479 2 -0.25090 0. 1 152
0.000781 80.24479 -0.125579 0.156494 2 -0.125 2 0.15641
0.000 91 80.18210 -0.062691 0.078186 2 -0.0626 0.078166
0.000195 80.15078 -0.0 1 21 0.0 9078 -0.0 1 0 0.0 907
9.77 -05 80.1 512 -0.015654 0.0195 5 -0.01565 0.0195 4
4.88 -05 80.127 0 -0.007826 0.009767 -0.00782 0.0097666/3/2011
Effect of Step Size in Forward
-
8/6/2019 Lecture on Numerical Differentiation
97/102
97
Effect of Step Size in Forward
Divided Difference Method
7
9
7 9
Number of times s tep size halved, n
f'(0.
2)
Initial step size=0.05
6/3/2011
Effect of Step Size on Approximate
-
8/6/2019 Lecture on Numerical Differentiation
98/102
98
Effect of Step Size on Approximate
Error
8
Number of times step size halved, n
Ea
Initial step size=0.05
6/3/2011
Effect of Step Size on Absolute
-
8/6/2019 Lecture on Numerical Differentiation
99/102
99
Effect of Step Size on Absolute
Relative Approximate Error
1
2
3
4
5
6
0 1 2 3 4 5 6 7 8 9 10 11 12
Nu be f t es step ze a e n
|Ea|%
Initial step size=0.05
6/3/2011
Effect of Step Size on Least
-
8/6/2019 Lecture on Numerical Differentiation
100/102
100
Number of Significant Digits
Correct
0
1
1 10 11
Number of times s tep size halved, n
Least
numberofsignific
antdigits
correct
Initial step size=0.05
6/3/2011
-
8/6/2019 Lecture on Numerical Differentiation
101/102
101
Effect of Step Size on True Error
Initial step size=0.05
00 10 1
Number mes step size halved, n
Et
Initial step size=0.05
6/3/2011
Effect of Step Size on Absolute
-
8/6/2019 Lecture on Numerical Differentiation
102/102
Effect of Step Size on Absolute
Relative True Error
0
2
1 0
1 2
1 2 10 1 1
Number oft mes step size halved, n
|Et|
%
Initial step size=0.05