PPT - Math For College

Download Report

Transcript PPT - Math For College

Differentiation-Continuous
Functions
Major: All Engineering Majors
Authors: Autar Kaw, Sri Harsha Garapati
http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
Undergraduates
4/13/2015
http://numericalmethods.eng.usf.edu
1
Differentiation – Continuous
Functions
http://numericalmethods.eng.usf.edu
Forward Difference Approximation
lim f x  Δx   f x 
f x  
Δx  0
Δx
For a finite ' Δx'
f  x  x   f  x 
f  x  
x
3
http://numericalmethods.eng.usf.edu
Graphical Representation Of
Forward Difference
Approximation
f(x)
x
x+Δx
Figure 1 Graphical Representation of forward difference approximation of first derivative.
4
http://numericalmethods.eng.usf.edu
Example 1
The velocity of a rocket is given by


14  104
 t   2000ln 
  9.8t,0  t  30
4
14

10

2100
t


where 'ν' is given in m/s and 't ' is given in seconds.
a) Use forward difference approximation of the first derivative of ν t  to
calculate the acceleration at t  16 s . Use a step size of Δt  2s .
b) Find the exact value of the acceleration of the rocket.
c) Calculate the absolute relative true error for part (b).
5
http://numericalmethods.eng.usf.edu
Example 1 Cont.
Solution
a ti  
 ti 1   ti 
t
ti  16
Δt  2
ti 1  ti  t
 16  2
 18
a16  
6
 18   16 
2
http://numericalmethods.eng.usf.edu
Example 1 Cont.


14  104
 18  2000ln 
 9.818

4
14  10  210018
 453 .02m/s


14104
 16  2000ln 
  9.816
4
1410  210016
 392 .07 m/s
Hence
a16  
7
 18   16 
2
http://numericalmethods.eng.usf.edu
Example 1 Cont.

453 .02  392 .07
2
 30.474m/s2
b) The exact value of a16 can be calculated by differentiating


14104
 t   2000ln 
  9.8t
4
1410  2100t 
as
a t  
8
d
νt 
dt
http://numericalmethods.eng.usf.edu
Example 1 Cont.
Knowing that
d
lnt   1
dt
t
and
d 1
1


dt  t 
t2
 14  104  2100t  d 

14  104


a t   2000
4
 dt  14  104  2100t   9.8
14

10

 

4

 14104  2100t 
14

10
 1
 2000
4
 14104  2100t
1410





9

 2100  9.8
2 


 4040  29.4t
 200  3t
http://numericalmethods.eng.usf.edu
Example 1 Cont.
a16 
 4040 29.416
 200  316
 29.674m/s2
The absolute relative true error is
t 

T rue Value - Approximate Value
x100
T rue Value
29.674 30.474
x100
29.674
 2.6967 %
10
http://numericalmethods.eng.usf.edu
Backward Difference Approximation of the
First Derivative
We know
lim f x  Δx   f x 
f x  
Δx  0
Δx
For a finite ' Δx' ,
f  x  
f  x  x   f  x 
x
If ' Δx' is chosen as a negative number,
f  x  

11
f  x  x   f  x 
 x
f  x   f  x  Δx 
Δx
http://numericalmethods.eng.usf.edu
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 f x  at x  xi, we may choose another
point ' Δx' behind as x  x . This gives
f  xi  

f  xi   f  xi 1 
x
i 1
f xi   f xi 1 
xi  xi 1
where
Δx  xi  xi 1
12
http://numericalmethods.eng.usf.edu
Backward Difference Approximation of the
First Derivative Cont.
f(x)
x
x-Δx
x
Figure 2 Graphical Representation of backward difference
approximation of first derivative
13
http://numericalmethods.eng.usf.edu
Example 2
The velocity of a rocket is given by


14  104
 t   2000ln 
  9.8t,0  t  30
4
14

10

2100
t


where 'ν' is given in m/s and 't ' is given in seconds.
a) Use backward difference approximation of the first derivative of ν t 
to calculate the acceleration at t  16 s . Use a step size of Δt  2s .
b) Find the absolute relative true error for part (a).
14
http://numericalmethods.eng.usf.edu
Example 2 Cont.
Solution
at  
 ti   ti 1 
t
ti  16
Δt  2
ti 1  ti  t
 16  2
 14
a16  
15
 16   14 
2
http://numericalmethods.eng.usf.edu
Example 2 Cont.


14  104
 16  2000ln 
 9.816

4
14  10  210016
 392 .07 m/s


14  104
 14  2000ln 
 9.814

4
14  10  210014
 334 .24 m/s
a16  

 16   14 
2
392 .07  334 .24
2
 28.915m/s2
16
http://numericalmethods.eng.usf.edu
Example 2 Cont.
The exact value of the acceleration at t  16 s from Example 1 is
a16  29.674m/s2
The absolute relative true error is
t 
29.674  28.915
x100
29.674
 2.5584 %
17
http://numericalmethods.eng.usf.edu
Derive the forward difference approximation
from Taylor series
Taylor’s theorem says that if you know the value of a function ' f ' at a point
xi
and all its derivatives at that point, provided the derivatives are
continuous between
xi and xi 1 , then
f xi 1   f xi   f xi  xi 1  xi  
f  xi 
xi 1  xi 2  
2!
Substituting for convenience Δx  xi 1  xi
f  xi 1   f  xi   f  xi Δx 
f xi  
f xi  
18
f xi 
Δx 2  
2!
f xi 1   f xi  f xi 
x   

x
2!
f xi 1   f xi 
 0x 
x
http://numericalmethods.eng.usf.edu
Derive the forward difference approximation
from Taylor series Cont.
The 0x 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 of0x

Can we get better approximations? Yes, another method to approximate
the first derivative is called the Central difference approximation of
the first derivative.
19
http://numericalmethods.eng.usf.edu
Derive the forward difference approximation
from Taylor series Cont.
From Taylor series
f xi 1   f xi   f xi Δx 
 
f xi 
Δx 2  f xi Δx 3  
2!
3!
f xi 1   f xi   f xi Δx 
 
f xi 
Δx 2  f xi Δx 3  
2!
3!
Subtracting equation (2) from equation (1)
f  xi 1   f xi 1   f xi 2Δx  
f xi  
f xi  
20
2 f xi 
Δx 3  
3!
f xi 1   f xi 1  f xi 
x 2  

2x
3!
f xi 1   f xi 1 
2
 0x 
2x
http://numericalmethods.eng.usf.edu
Central Divided Difference
Hence showing that we have obtained a more accurate formula as the
error is of the order of 0Δx 2.
f(x)
x
x-Δx
x
x+Δx
Figure 3 Graphical Representation of central difference approximation of first derivative
21
http://numericalmethods.eng.usf.edu
Example 3
The velocity of a rocket is given by


14  104
 t   2000ln 
  9.8t,0  t  30
4
14

10

2100
t


where 'ν' is given in m/s and 't ' is given in seconds.
(a) Use central divided difference approximation of the first derivative of ν t 
to calculate the acceleration at t  16 s . Use a step size of Δt  2s .
(b) Find the absolute relative true error for part (a).
22
http://numericalmethods.eng.usf.edu
Example 3 cont.
Solution
ati  
 ti 1   ti 1 
ti  16
t  2
2t
ti 1  ti  t
 16  2
 18
ti 1  ti  t
 16  2
 14
a16 
23
 18  14
22
 18   14 

4
http://numericalmethods.eng.usf.edu
Example 3 cont.


14  104
 18  2000ln 
 9.818

4
14  10  210018
 453 .02m/s


14  104
 14  2000ln 
 9.814

4
14  10  210014
 334 .24 m/s
a16  
 18   14 
4
453 .02  334 .24

4
 29.694m/s2
24
http://numericalmethods.eng.usf.edu
Example 3 cont.
The exact value of the acceleration at t  16 s from Example 1 is
a16  29.674m/s2
The absolute relative true error is
t 
29.674 29.694
100
29.674
 0.069157 %
25
http://numericalmethods.eng.usf.edu
Comparision of FDD, BDD, CDD
The results from the three difference approximations are given in Table 1.
Table 1 Summary of a (16) using different divided difference approximations
Type of Difference
Approximation
Forward
Backward
Central
26
a16
m / s 
2
30.475
28.915
29.695
t %
2.6967
2.5584
0.069157
http://numericalmethods.eng.usf.edu
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
vt 
for


14  104
 t   2000ln 
  9.8t
4
14

10

2100
t


at t  16 using the backward divided difference scheme.
27
http://numericalmethods.eng.usf.edu
Finding the value of the derivative
within a prespecified tolerance Cont.
Given in Table 2 are the values obtained using the backward difference
approximation method and the corresponding absolute relative
approximate errors.
Table 2 First derivative approximations and relative errors for
different Δt values of backward difference scheme
t
2
1
0.5
0.25
0.125
28
vt 
28.915
29.289
29.480
29.577
29.625
a %
1.2792
0.64787
0.32604
0.16355
http://numericalmethods.eng.usf.edu
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 t  0.125
the absolute relative approximate error is 0.16355%, meaning that
at least 2 significant digits are correct in the answer.
29
http://numericalmethods.eng.usf.edu
Finite Difference Approximation of
Higher Derivatives
One can use Taylor series to approximate a higher order derivative.
For example, to approximate f x , the Taylor series for
f xi  2   f xi   f xi 2Δx  
 
f xi 
2Δx 2  f xi 2Δx 3  
2!
3!
where
xi  2  xi  2Δx
f xi 1   f xi   f xi x  
f xi 
f xi 
2
x  
x 3 
2!
3!
where
xi 1  xi  Δx
30
http://numericalmethods.eng.usf.edu
Finite Difference Approximation of
Higher Derivatives Cont.
Subtracting 2 times equation (4) from equation (3) gives
f xi 2   2 f xi 1    f xi   f xi Δx  f xi Δx 
2
f xi  
f xi  
31
f xi 2   2 f xi 1   f xi 
Δx
2
 f xi Δx   
f xi  2   2 f xi 1   f xi 
Δx 
2
3
 0Δx 
(5)
http://numericalmethods.eng.usf.edu
Example 4
The velocity of a rocket is given by


14  104
 t   2000ln 
 9.8t,0  t  30

4
14  10  2100t 
Use forward difference approximation of the second derivative ν t 
of to calculate the jerk at t  16 s. Use a step size of Δt  2s .
32
http://numericalmethods.eng.usf.edu
Example 4 Cont.
Solution
j ti  
 ti  2   2 ti 1   ti 
ti  16
t  2
t 2
ti 1  ti  t
 16  2
 18
ti  2  ti  2t 
 16  22
 20
j 16 
33
 20  2 18  16
22
http://numericalmethods.eng.usf.edu
Example 4 Cont.


14  104
 20  2000ln 
 9.820

4
14  10  210020
 517 .35 m/s


14  104
 18  2000ln 
 9.818

4
14  10  210018
 453 .02 m / s


14  104
 16  2000ln 
  9.816
4


14

10

2100
16


 392 .07 m/s
34
http://numericalmethods.eng.usf.edu
Example 4 Cont.
j 16  
517 .35  2453 .02   392 .07
4
 0.84515m/s3
The exact value of j 16 can be calculated by differentiating


14  104
 t   2000ln 
  9.8t
4
14

10

2100
t


twice as
d
νt 
a t  
dt
35
and j t  
d
at 
dt
http://numericalmethods.eng.usf.edu
Example 4 Cont.
Knowing that
d
lnt   1
dt
t
and
d 1
1


dt  t 
t2
 14  104  2100t  d 

14  104


a t   2000
4
 dt  14  104  2100t   9.8
14

10

 

4


 14  104  2100t 
14

10

 2100  9.8
 1
 2000
2 
4
4

14  10


 14  10  2100t  

36
 4040  29.4t
 200  3t
http://numericalmethods.eng.usf.edu
Example 4 Cont.
Similarly it can be shown that
d
j t   at 
dt
18000

(200 3t ) 2
j 16 
18000
[200  3(16)]2
 0.77909m/s3
The absolute relative true error is
t 
0.77909 0.84515
100
0.77909
 8.4797 %
37
http://numericalmethods.eng.usf.edu
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
f xi 1   f xi   f xi x 
 
 
f xi 
x 2  f xi x 3  f xi x 4 
2!
3!
4!
(6)
where
xi 1  xi  Δx
38
http://numericalmethods.eng.usf.edu
Higher order accuracy of higher
order derivatives Cont.
f xi 1   f xi   f xi x 
 
 
f xi 
x 2  f xi x 3  f xi x 4 
2!
3!
4!
(7)
where
xi 1  xi  Δx
Adding equations (6) and (7), gives
4

Δx 
f xi 1   f xi 1   2 f xi   f xi Δx   f xi 
2
12
f xi  
f xi  
39
f xi 1   2 f xi   f xi 1 
Δx2
f xi Δx 

12
f xi 1   2 f xi   f xi 1 
Δx2
2
 0Δx 
2
http://numericalmethods.eng.usf.edu
Example 5
The velocity of a rocket is given by


14  104
 t   2000ln 
 9.8t,0  t  30

4
14  10  2100t 
Use central difference approximation of second derivative of ν t  to
calculate the jerk at t  16 s . Use a step size of Δt  2s.
40
http://numericalmethods.eng.usf.edu
Example 5 Cont.
Solution
ati  
 ti 1   2 ti   ti 1 
t i  16
t 2
t  2
ti 1  ti  t
 16  2
 18
ti 1  ti  t
 16  2
 14
j 16 
41
 18  2 16  14
22
http://numericalmethods.eng.usf.edu
Example 5 Cont.


14  104
 18  2000ln 
  9.818
4


14

10

2100
18


 453 .02m/s


14  104
 16  2000ln 
  9.816
4


14

10

2100
16


 392 .07 m/s


14  104


 14  2000ln 
 9.814

4
14  10  210014
 334 .24 m/s
42
http://numericalmethods.eng.usf.edu
Example 5 Cont.
j 16 

 18  2 16  14
22
453 .02  2392 .07   334 .24
4
 0.77969m/s3
The absolute relative true error is
t 
0.77908 0.78
 100
0.77908
 0.077992 %
43
http://numericalmethods.eng.usf.edu
Additional Resources
For all resources on this topic such as digital audiovisual
lectures, primers, textbook chapters, multiple-choice tests,
worksheets in MATLAB, MATHEMATICA, MathCad and
MAPLE, blogs, related physical problems, please visit
http://numericalmethods.eng.usf.edu/topics/continuous_02
dif.html
THE END
http://numericalmethods.eng.usf.edu