0% found this document useful (0 votes)
11 views79 pages

Introduction To Numerical Method

Uploaded by

Mutasem abadleh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views79 pages

Introduction To Numerical Method

Uploaded by

Mutasem abadleh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 79

Introduction to Numerical Method

Dr. Mohammad Almajali

3/1/2021 1
Why use Numerical Methods?
• To solve problems that cannot be solved exactly
x u2
1 

2 

e 2
du

• To solve problems that


are intractable!
How do we solve an engineering problem?

Problem Description

Mathematical Model

Solution of Mathematical Model

Using the Solution


3
Example of Solving an Engineering Problem

Bascule Bridge

4
Bascule Bridge

Hub

Trunnion

Girder

5
Trunnion-Hub-Girder
Assembly Procedure

Step1. Trunnion immersed in dry-ice/alcohol


Step2. Trunnion warm-up in hub
Step3. Trunnion-Hub immersed in
dry-ice/alcohol
Step4. Trunnion-Hub warm-up into girder

6
Problem

After Cooling, the Trunnion Got Stuck in Hub

Why did it get stuck?


Magnitude of contraction needed in the trunnion was 0.015” or
more. Did it contract enough?
7
Consultant calculations

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

D  D   (T )dT Ta=80oF; Tc=-108oF; D=12.363”


Ta

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.2278105 T 2  6.1946103 T  6.0150

13
So what is the solution to the problem?

One solution is to immerse the trunnion in liquid


nitrogen which has a boiling point of -321oF as
opposed to the dry-ice/alcohol temperature of -108oF.

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

3) Solution: 1) Used trapezoidal rule OR b)


Used regression and integration.
4) Implementation: Cool the trunnion in liquid
nitrogen.
15
Mathematical Procedures

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?

Some examples of Taylor series which you must have


seen
x2 x4 x6
cos(x)  1    
2! 4! 6!

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!

provided that all derivatives of f(x) are continuous and


exist in the interval [x,x+h]

What does this mean in plain English?


As Archimedes would have said, “Give me the value of the function
at a single point, and the value of all (first, second, and so on) its
derivatives at that single point, and I can give you the value of the
function at any other point” (fine print excluded)

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!
x4
h  64  2
21
Example (cont.)
Solution: (cont.)
Since the higher order derivatives are zero,
22 23
f 4  2  f 4  f 42  f 4  f 4
2! 3!
 2 2   23 
f 6  125  742  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 0h  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

f n (0)  e 0  1 the Maclaurin series is then

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

For a finite ' Δx'

f  x  x   f  x 
f  x  
x

30
Graphical Representation Of Forward
Difference Approximation

f(x)

x x+Δx

Figure 1 Graphical Representation of forward difference approximation of first derivative.

31
Example 1
The velocity of a rocket is given by

 14 104 
 t   2000ln    9.8t ,0  t  30
14 10  2100t 
4

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  16s . 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).

32
Example 1 Cont.
Solution  ti 1   ti 
ati  
t

ti  16 Δt  2

ti 1  ti  t
 16  2
 18

 18  16
a16 
2

33
Example 1 Cont.
 14 104 
 18  2000ln    9.818  453.02m/s
14 10  210018
4

 14 104 
 16  2000ln    9.816  392.07m/s
14 10  210016
4

Hence
 18  16
a16 
2

34
Example 1 Cont.
453.02  392.07  30.474m/s 2

2
b) The exact value of a16 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
lnt  
d 1 1
   2
dt t dt  t  t

 14  104  2100t  d  14  104 


a t   2000     9.8
 14  10 4
 dt  14  10  2100t 
4

 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.416
a 16 
 200  316

 29.674m/s 2

The absolute relative true error is

True Value - Approximat e Value


t  x100
True Value
29.674  30.474
 x100
29.674

 2.6967%
37
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  x   f  x 
f  x  
x

If ' Δx' is chosen as a negative number,

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

Figure 2 Graphical Representation of backward difference


approximation of first derivative

40
Example 2
The velocity of a rocket is given by

 14 104 
 t   2000ln    9.8t ,0  t  30
14 10  2100t 
4

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).

41
Example 2 Cont.
Solution

 ti   ti 1 
a t  
t
ti  16
Δt  2

ti 1  ti  t
 16  2
 14

 16  14
a16 
2
42
Example 2 Cont.
 14  104 
 
 16  2000ln    9.816
14  10  210016
4

 392.07m/s
 14  104 
 14  2000ln    9.814
14  10  210014
4

 334.24m/s
 16  14
a16 
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

a16  29.674m/s2

The absolute relative true error is

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

continuous between xi and xi 1 , then


f xi 
f  xi 1   f  xi   f  xi  xi 1  xi   xi 1  xi 2  
2!
Substituting for convenience Δx  xi 1  xi
f  xi 
f  xi 1   f  xi   f  xi Δx  Δx 2  
2!
f xi 1   f xi  f xi 
f xi    x   
x 2!
f xi 1   f xi 
f xi    0x 
x
45
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 of 0x 


Can we get better approximations? Yes, another method to approximate

the first derivative is called the Central 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!

Subtracting equation (2) from equation (1)


2 f xi 
f  xi 1   f  xi 1   f  xi 2Δx   Δx 3  
3!
f xi 1   f xi 1  f xi 
f xi    x 2  
2x 3!
f xi 1   f xi 1 
f  xi  
  0x 
2

2x

47
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

48
Example 3
The velocity of a rocket is given by

 14  104 
 t   2000ln    9.8t ,0  t  30
14  10  2100t 
4

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  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 
ati  
2t
ti  16 t  2
ti 1  ti  t ti 1  ti  t
 16  2  16  2
 18  14

 18  14
a16 
22
 18  14

4

50
Example 3 cont.
 14  104 
 18  2000ln    9.818  453.02m/s
14  10  210018
4

 14  104 
 14  2000ln    9.814  334.24m/s
14  10  210014
4

 18  14
a16 
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

a16  29.674m/s 2

The absolute relative true error is

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.

Table 1 Summary of a (16) using different divided difference approximations

Type of Difference a16


t %
Approximation m / s 
2

Forward 30.475 2.6967


Backward 28.915 2.5584
Central 29.695 0.069157

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.

Take the example of finding vt  for

 14  104 
 t   2000ln    9.8t
14  10  2100t 
4

at t  16 using the backward divided difference scheme.

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.

Table 2 First derivative approximations and relative errors for


different Δt values of backward difference scheme

t vt  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.

For example, to approximate f x  , the Taylor series for


f xi  f xi 
f xi  2   f xi   f xi 2x   2x   2x 3  (3)
2

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

f xi  2   2 f xi 1    f xi   f xi Δx   f xi Δx  


2 3

f xi  2   2 f xi 1   f xi 


f xi    f xi Δx   
Δx  2

f xi  2   2 f xi 1   f xi 


f xi    0Δx  (5)
Δx  2

58
Example 4
The velocity of a rocket is given by

 14  104 
 t   2000ln    9.8t ,0  t  30
14  10  2100t 
4

Use forward difference approximation of the second derivative  t 


of to calculate the jerk at t  16s. Use a step size of Δt  2s.

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  2t 
 16  22
 20
 20  2 18  16
j 16 
2 2

60
Example 4 Cont.
 14  104 
 20  2000ln    9.820
14  10  210020
4

 517.35m/s
 14  104 
 18  2000ln    9.818
14  10  210018
4

 453.02m/ s
 14  104 
 16  2000ln    9.816
14  10  210016
4

 392.07m/s
61
Example 4 Cont.
517.35  2453.02  392.07
j 16 
4
 0.84515m/s3

The exact value of j 16 can be calculated by differentiating

 14  104 
 t   2000ln    9.8t
14  10  2100t 
4

twice as

a t  
d
νt  and
j t  
d
at 
dt
dt

62
Example 4 Cont.
Knowing that

d 1 1
d
lnt   1 and
dt  t 
 
t2
dt t

 14  104  2100t  d  14  104 


a t   2000 
 
   9.8
 14  10 4
 dt  14  10  2100t 
4

 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
at 
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

approximation of the second derivative.

The Taylor series for

f xi      (6)


f xi 1   f xi   f xi x  x 2  f xi x 3  f xi x 4 
2! 3! 4!
where
xi 1  xi  Δx
65
Higher order accuracy of higher order
derivatives Cont.
f xi  f xi  f xi 
f xi 1   f xi   f xi x  x   x   x 4  (7)
2 3

2! 3! 4!

where xi 1  xi  Δx
Adding equations (6) and (7), gives

f xi 1   f xi 1   2 f xi   f xi Δx   f xi 


2 Δx 4

12
f xi 1   2 f xi   f xi 1  f xi Δx 
2

f xi   
Δx 2 12

f xi 1   2 f xi   f xi 1 


f xi    0Δx 
2

Δ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

Use central difference approximation of second derivative of νt  to


calculate the jerk at t  16s. Use a step size of Δt  2s.

67
Example 5 Cont.
Solution

 ti 1   2 ti   ti 1 


ati  
t 2
t i  16 t  2

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.818
14  10  210018
4

 453.02m/s
 14 104 
 16  2000ln    9.816
14 10  210016
4

 392.07m/s
 14  104 
 14  2000ln    9.814
14  10  210014
4

 334.24m/s
69
Example 5 Cont.
 18  2 16  14
j 16 
22
453.02  2392.07  334.24

4
 0.77969m/s 3

The absolute relative true error is

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

Figure 1 Graphical Representation of forward difference approximation of first derivative.

73
Example 1
The upward velocity of a rocket is given as a function of time in Table 1.

Table 1 Velocity as a function of time

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 forward divided difference, find the acceleration of the rocket at t  16 s .


74
Example 1 Cont.
Solution

To find the acceleration at t  16s, we need to choose the two values


closest to t  16s, that also bracket t  16s to evaluate it. The two
points are t  15s and t  20s.

 ti 1   ti  ti  15
ati  
t
ti 1  20 t  ti 1  ti
 20  15
5
75
Example 1 Cont.
 20  15
a16 
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

Pn x  a0  a1x    an 1xn 1  an xn

To find the first derivative,

Pn x    a1  2a 2 x    n  1a n 1 x n 2  nan x n 1


dPn ( x )
dx
Similarly other derivatives can be found.

77
Example 2-Direct Fit Polynomials
The upward velocity of a rocket is given as a function of time in Table 2.

Table 2 Velocity as a function of time

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

vt   a0  a1t  a2 t 2  a3t 3


Since we want to find the velocity at t  16 s, and we are using third order polynomial, we need
to choose the four points closest to t  16 s and that also bracket t  16 s to evaluate it.

The four points are to  10, t1  15, t2  20, and t3  22.5.

to  10, vto   227.04

t1  15, vt1   362.78


t2  20, vt2   517.35
t3  22.5, vt3   602.97
79
Example 2-Direct Fit Polynomials cont.

such that

v10  227.04  a0  a1 10  a 2 10  a3 10


2 3

v15  362.78  a0  a1 15  a2 15  a3 15


2 3

v20  517.35  a0  a1 20  a2 20  a3 20


2 3

v22.5  602.97  a0  a1 22.5  a2 22.5  a3 22.5


2 3

Writing the four equations in matrix form, we have

1 10 100 1000  a 0  227.04


1 15 225 3375   a  362.78
  1    
1 20 400 8000  a 2  517.35
    
1 22.5 506.25 11391 3  
a 602.97

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

vt   a0  a1t  a2t 2  a3t 3


 4.3810  21.289t  0.13065t 2  0.0054606t 3 , 10  t  22.5

81
Example 2-Direct Fit Polynomials cont.

Figure 1 Graph of upward velocity of the rocket vs. time.

82
, Example 2-Direct Fit Polynomials cont.
The acceleration at t=16 is given by

a 16  vt  t 16


d
dt
Given that
 t   4.3810  21.289t  0.13065t 2  0.0054606t 3 ,10  t  22.5

a t   vt 
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

a16  21.289  0.2613016  0.01638216


2

 29.664m/s 2
83

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy