Introduction To Numerical Method
Introduction To Numerical Method
3/1/2021 1
Why use Numerical Methods?
• To solve problems that cannot be solved exactly
x u2
1
2
e 2
du
Problem Description
Mathematical Model
Bascule Bridge
4
Bascule Bridge
Hub
Trunnion
Girder
5
Trunnion-Hub-Girder
Assembly Procedure
6
Problem
D D T
D 12.363"
6.47 10 in / in / F
6 o
T 108 80 188 F o
6
D (12.363)(6.47 10 )(188)
0.01504"
8
Is the formula used correct?
D D T T(oF) α (μin/in/oF)
-340 2.45
-300 3.07
-220 4.08
-160 4.72
D D T
-80 5.43
0 6.00
40 6.24
80 6.47
9
The Correct Model Would Account for Varying
Thermal Expansion Coefficient
Tc
D D (T )dT
Ta
10
Can You Roughly Estimate the Contraction?
Tc
Tc
D D (T )dT
Ta
http://numericalmethods.eng.usf.edu 11
Can You Find a Better Estimate for the
Contraction?
Tc
D D (T )dT
Ta
Ta = 80oF
Tc = -108oF
D = 12.363"
12
Estimating Contraction Accurately
Change in diameter
(D) by cooling it in dry
ice/alcohol is given by
Tc
D D (T )dT
Ta
D 0.0137"
Ta = 80oF
Tc = -108oF
D = 12.363"
1.2278105 T 2 6.1946103 T 6.0150
13
So what is the solution to the problem?
D 0.0244"
14
Revisiting steps to solve a problem
1) Problem Statement: Trunnion got stuck in
the hub.
2) Modeling: Developed a new model
Tc
D D (T )dT
Ta
16
Mathematical Procedures
• Nonlinear Equations
• Differentiation
• Simultaneous Linear Equations
• Curve Fitting
• Interpolation
• Regression
• Integration
• Ordinary Differential Equations
• Other Advanced Mathematical Procedures:
• Partial Differential Equations
• Optimization
• Fast Fourier Transforms
17
Taylor Series Revisited
3/1/2021 18
What is a Taylor series?
x3 x5 x7
sin( x) x
3! 5! 7!
2 3
x x
e 1 x
x
2! 3!
19
General Taylor Series
The general form of the Taylor series is given by
f x 2 f x 3
f x h f x f x h h h
2! 3!
20
Example—Taylor Series
Find the value of f 6 given that f 4 125, f 4 74,
f 4 30, f 4 6 and all other higher order derivatives
of f x at x 4 are zero.
Solution:
h2 h3
f x h f x f x h f x f x
2! 3!
x4
h 64 2
21
Example (cont.)
Solution: (cont.)
Since the higher order derivatives are zero,
22 23
f 4 2 f 4 f 42 f 4 f 4
2! 3!
2 2 23
f 6 125 742 30 6
2! 3!
125 148 60 8 341
Note that to find f 6 exactly, we only need the value
of the function and all its derivatives at some other
point, in this case x 4
22
Derivation for Maclaurin Series for ex
Derive the Maclaurin series
2 3
x x
e 1 x
x
2! 3!
The Maclaurin series is simply the Taylor series about
the point x=0
h2 h3 h4 h5
f x h f x f x h f x f x f x f x
2! 3! 4 5
h2 h3 h4 h5
f 0 h f 0 f 0h f 0 f 0 f 0 f 0
2! 3! 4 5
23
Derivation (cont.)
Since f ( x) e , f ( x) e , f ( x) e , ... , f ( x) e
x x x n x
and
0 0
( e ) ( e ) 3
f ( h ) (e ) (e ) h
0 0
h
2
h ...
2! 3!
1 2 1 3
1 h h h ...
2! 3!
So,
2 3
x x
f ( x) 1 x ...
2! 3!
24
Differentiation-Continuous Functions
3/1/2021 29
Forward Difference Approximation
lim f x Δx f x
f x
Δx 0 Δx
f x x f x
f x
x
30
Graphical Representation Of Forward
Difference Approximation
f(x)
x x+Δx
31
Example 1
The velocity of a rocket is given by
14 104
t 2000ln 9.8t ,0 t 30
14 10 2100t
4
32
Example 1 Cont.
Solution ti 1 ti
ati
t
ti 16 Δt 2
ti 1 ti t
16 2
18
18 16
a16
2
33
Example 1 Cont.
14 104
18 2000ln 9.818 453.02m/s
14 10 210018
4
14 104
16 2000ln 9.816 392.07m/s
14 10 210016
4
Hence
18 16
a16
2
34
Example 1 Cont.
453.02 392.07 30.474m/s 2
2
b) The exact value of a16 can be calculated by differentiating
14 104
t 2000ln 9.8t
14 10 2100t
4
as
a t νt
d
dt
35
Example 1 Cont.
Knowing that
and d 1
lnt
d 1 1
2
dt t dt t t
14 104 2100t 4
1 2100 9.8
14 10
2000
14 10 4
14 104 2100t
2
4040 29.4t
200 3t
36
Example 1 Cont.
4040 29.416
a 16
200 316
29.674m/s 2
2.6967%
37
Backward Difference Approximation of the
First Derivative
We know lim f x Δx f x
f x
Δx 0 Δx
f x x f x f x f x Δx
f x
x Δx
38
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 x , we may choose another
i
point ' Δx' behind as x x . This gives
i 1
f xi f xi 1 f xi f xi 1
f xi
x xi xi 1
where
Δx xi xi 1
39
Backward Difference Approximation of the First Derivative
Cont.
f(x)
x-Δx x
40
Example 2
The velocity of a rocket is given by
14 104
t 2000ln 9.8t ,0 t 30
14 10 2100t
4
41
Example 2 Cont.
Solution
ti ti 1
a t
t
ti 16
Δt 2
ti 1 ti t
16 2
14
16 14
a16
2
42
Example 2 Cont.
14 104
16 2000ln 9.816
14 10 210016
4
392.07m/s
14 104
14 2000ln 9.814
14 10 210014
4
334.24m/s
16 14
a16
2
392.07 334.24 28.915m/s2
2
43
Example 2 Cont.
The exact value of the acceleration at t 16 s from Example 1 is
a16 29.674m/s2
29.674 28.915
t x100
29.674
2.5584%
44
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
The 0x 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?
46
Derive the forward difference approximation
from Taylor series Cont.
From Taylor series
f xi
x 2 f xi x 3 (1)
f xi 1 f xi f xi x
f xi f xi
2! 3!
f xi 1 f xi f xi x x x 3 (2)
2
2! 3!
2x
47
Central Divided Difference
Hence showing that we have obtained a more accurate formula as the
f(x)
x
x-Δx x x+Δx
48
Example 3
The velocity of a rocket is given by
14 104
t 2000ln 9.8t ,0 t 30
14 10 2100t
4
(a) Use central divided difference approximation of the first derivative of νt
to calculate the acceleration at t 16s . Use a step size of Δt 2s .
(b) Find the absolute relative true error for part (a).
49
Example 3 cont.
Solution ti 1 ti 1
ati
2t
ti 16 t 2
ti 1 ti t ti 1 ti t
16 2 16 2
18 14
18 14
a16
22
18 14
4
50
Example 3 cont.
14 104
18 2000ln 9.818 453.02m/s
14 10 210018
4
14 104
14 2000ln 9.814 334.24m/s
14 10 210014
4
18 14
a16
4
453.02 334.24
4
29.694m/s 2
51
Example 3 cont.
The exact value of the acceleration at t 16 s from Example 1 is
a16 29.674m/s 2
29.674 29.694
t 100
29.674
0.069157%
52
Comparison of FDD, BDD, CDD
The results from the three difference approximations are given in Table 1.
53
Finding the value of the derivative within a
pre specified 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.
14 104
t 2000ln 9.8t
14 10 2100t
4
54
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.
t vt a %
2 28.915
1 29.289 1.2792
0.5 29.480 0.64787
0.25 29.577 0.32604
0.125 29.625 0.16355
55
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.
56
Finite Difference Approximation of Higher
Derivatives
One can use Taylor series to approximate a higher order derivative.
2! 3!
where xi 2 xi 2Δx
f xi f xi
f xi 1 f xi f xi x x x 3 (4)
2
2! 3!
where
xi 1 xi Δx
57
Finite Difference Approximation of Higher
Derivatives Cont.
Subtracting 2 times equation (4) from equation (3) gives
58
Example 4
The velocity of a rocket is given by
14 104
t 2000ln 9.8t ,0 t 30
14 10 2100t
4
59
Example 4 Cont.
Solution
ti 2 2 ti 1 ti
j ti ti 16
t 2
t 2 ti 1 ti t
16 2
18
ti 2 ti 2t
16 22
20
20 2 18 16
j 16
2 2
60
Example 4 Cont.
14 104
20 2000ln 9.820
14 10 210020
4
517.35m/s
14 104
18 2000ln 9.818
14 10 210018
4
453.02m/ s
14 104
16 2000ln 9.816
14 10 210016
4
392.07m/s
61
Example 4 Cont.
517.35 2453.02 392.07
j 16
4
0.84515m/s3
14 104
t 2000ln 9.8t
14 10 2100t
4
twice as
a t
d
νt and
j t
d
at
dt
dt
62
Example 4 Cont.
Knowing that
d 1 1
d
lnt 1 and
dt t
t2
dt t
14 104 2100t 4
1 2100 9.8
14 10
2000
14 104
14 104 2100t
2
4040 29.4t
200 3t
63
Example 4 Cont.
Similarly it can be shown that
j t
d
at
dt
18000
(200 3t ) 2
j 16
18000
[200 3(16)]2
0.77909m/s3
The absolute relative true error is
0.77909 0.84515
t 100 8.4797 %
0.77909
64
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
2! 3! 4!
where xi 1 xi Δx
Adding equations (6) and (7), gives
12
f xi 1 2 f xi f xi 1 f xi Δx
2
f xi
Δx 2 12
Δx 2
66
Example 5
The velocity of a rocket is given by
14 104
t 2000ln 9.8t ,0 t 30
14 10 2100t
4
67
Example 5 Cont.
Solution
ti 1 ti t ti 1 ti t
16 2 16 2
18 14
18 2 16 14
j 16
2 2
68
Example 5 Cont.
14 104
18 2000ln 9.818
14 10 210018
4
453.02m/s
14 104
16 2000ln 9.816
14 10 210016
4
392.07m/s
14 104
14 2000ln 9.814
14 10 210014
4
334.24m/s
69
Example 5 Cont.
18 2 16 14
j 16
22
453.02 2392.07 334.24
4
0.77969m/s 3
0.77908 0.78
t
0.77908
100 0.077992%
70
Differentiation-Discrete Functions
3/1/2021 71
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
72
Graphical Representation Of
Forward Difference
Approximation
f(x)
x x+Δx
73
Example 1
The upward velocity of a rocket is given as a function of time in Table 1.
t v(t)
s m/s
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
ti 1 ti ti 15
ati
t
ti 1 20 t ti 1 ti
20 15
5
75
Example 1 Cont.
20 15
a16
5
517.35 362.78
5
30.914 m/s 2
76
Direct Fit Polynomials
In this method, given ' n 1' data points x0 , y 0 , x1 , y1 , x 2 , y 2 , , x n , y n
one can fit a n th order polynomial given by
77
Example 2-Direct Fit Polynomials
The upward velocity of a rocket is given as a function of time in Table 2.
t v(t)
s m/s
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
Using the third order polynomial interpolant for velocity, find the
acceleration of the rocket at t 16 s .
78
Example 2-Direct Fit Polynomials cont.
Solution
For the third order polynomial (also called cubic interpolation), we choose the velocity given by
such that
80
Example 2-Direct Fit Polynomials cont.
Solving the above four equations gives
a0 4.3810
a1 21.289
a2 0.13065
a3 0.0054606
Hence
81
Example 2-Direct Fit Polynomials cont.
82
, Example 2-Direct Fit Polynomials cont.
The acceleration at t=16 is given by
a t vt
d
dt
d
dt
4.3810 21.289t 0.13065t 2 0.0054606t 3
21.289 0.26130t 0.016382t 2 , 10 t 22.5
29.664m/s 2
83