Numerical Methods Lecture 1 PDF
Numerical Methods Lecture 1 PDF
Numerical Methods Lecture 1 PDF
Numerical Methods
Lecture 1
Dr Victoria Timchenko
School of Mechanical and Manufacturing
Engineering (J17)
Part1 Overview
What is MATH2089 about?
What are Numerical Methods?
How we approach “Problem solving”
Digital representation of numbers
Floating Point Arithmetic
Error analysis
Engineering Grand Challenges
Weather Balloon
Ozone Model
Tornado Machine
Engineering Grand Challenges
Improvements in
Vehicle Performance
Wind Tunnel
Objectives of the Course
Matlab computer
Satisfactory participation in Throughout
laboratory 15
laboratory classes Semester
participation
Total 100
Labs/Tuts MATH2089
Week2: Lab work Matlab fundamentals (3)
Week3: Tutorial work on data representation, error analysis
Week4: Matlab laboratory work on nonlinear equations (3)
Week5: Tutorial work on nonlinear equations
Week6: 30-35 min Matlab test/ Matlab laboratory work on systems of
equations
Week7: 30-35 min tutorial Quizz on nonlinear equations and systems of
equations.
Week8: Laboratory work on curve fitting and polynomial approximation
(3)
Week9: Tutorial work on numerical differentiation and integration
Week10: Laboratory work on ODE (Euler & Heun methods) (3)
Week11: Tutorial work on ODE
Week12: Laboratory work on PDE (3)
Week13: Tutorial work on PDE & review.
5 labs each 3 =15 marks in total assessment
What are Numerical Methods and why to study them?
ax 2 bx c 0 Quadratic equation
ax b 0
Can be solved analytically
ax 2 bx c 0
v (t ) t
tanh( 2 gh )
2 gh 2L
r
2vmax 0 r 1/ n
vave 2 r (1 ) dr
r0 0 r0
Problem definition
Determine the terminal velocity of a free-falling body near
the earth’s surface
Air resistance is linearly proportional to velocity, FU cv
Initial condition of v = 0 at t = 0
v is dependent variable, t is independent variable
Example: Solution (con’t)
Mathematical model
dv F
Newton’s second law: F ma
dt m
dv c
F FD FU mg cv dt
g v
m
dv m c
a) Analytical method: c dt ln g v t A
g v c m
m
where A is an integrating constant
m
Initial condition of v = 0 at t = 0; A ln g
c
gm
Analytical solution: v(t )
c
1 e ( c m ) t or v (t ) 53.311 e 0.1838t
Example: Solution (con’t)
b) Numerical method : The time rate change of velocity can be
approximated as:
v (ti 1 ) v (ti ) c
g v (ti )
ti 1 ti m
Numerical solution:
c
v (ti 1 ) v (ti ) g v (ti ) (ti 1 ti )
New value Old value
m step size t
40
v, m/s
20
0
0 4 t, s 8 12
Example: Solution (con’t)
b) Numerical solution:
Velocity of parachutist
60
50
40
v (m/s)
30
20 Analytical Solution
Euler solution with dt=2s
Euler solution with dt=1s
RK solution
10
0
0 2 4 6 8 10 12 14 16 18 20
t (sec)
Conservation laws in engineering and science
For example,
for steady state incompressible fluid
flow in pipes
In decimal form:
In binary form:
( N )10 (ak 2k ) (ak 1 2k 1 ) ... ( a1 21 ) ( a0 20 )
N ak ak 1...a2 a1a0two
Binary Storage of Integers
Integers can be exactly represented by base 2
Limitations:
A finite number of bits are used to store each value
in computer memory
Limiting the number of bits limits the size of integer
that can be represented
Matlab:
Machine Precision
The magnitude of round-off errors is quantified by machine
precision εm.
There is a number, εm > 0, such that
1+δ=1 whenever |δ| < εm.
In exact arithmetic 1 + δ = 1 only when δ = 0, so in exact
arithmetic εm is identically zero.
Matlab uses double precision (64 bit) arithmetic. The built-in
variables eps stores the value of εm
eps = 2.2204 × 10−16
Underflow, Overflow and Not-a-Number
Any number that is less than the smallest floating point
number underflows to 0
>>x=29/1300
x=0.223
>>y=29-1300*x
y=3.5527e-015
It turns out that the cause was an inaccurate calculation of the time since
boot due to computer arithmetic errors. Specifically, the time in tenths of
second as measured by the system's internal clock was multiplied by 1/10
to produce the time in seconds. This calculation was performed using a
24 bit fixed point register.
24 bit timer stored 0.00011001100110011001100
Error = 0.0000000000000000000000011001100 . . . binary
≈ 9.5 10−8
Timer running 100 hours : error = 9.5 10−8 × 100 × 60 × 60 × 10 = 0.34
secs
Scud 1, 676 m/sec : error > 0.5 km
Error Analysis
If x is an approximation to x
x x 1 d
10
x 2
Sources of Error
(1) Errors in mathematical modelling: the simplifying approximations
and assumptions made in representing a physical system by
mathematical equation introduce error.
(2) Blunders: the programming errors, if undetected, introduce errors to
the computed values.
(3) Errors in input: due to the errors in data transfer and the
uncertainties associated with measurements.
(4) Machine errors: the floating point representation of numbers involves
rounding and chopping errors, as well as underflow and overflow
errors. These errors are introduced at each arithmetic operation
during computation.
(5) Truncation errors associated with the mathematical process: for
example, the approximate evaluation of an infinite series or an integral
involving infinity as a limit of integration involve computational errors.
Round-off Error
Since only a finite number of digits are stored in a
computer, the actual numbers may undergo chopping or
rounding of the last digit.
Effects of round-off usually accumulate slowly, but . . .
Subtracting nearly equal numbers leads to severe loss of
precision.
A similar loss of precision occurs when two numbers of
very different magnitude are added.
Round-off is inevitable: good algorithms minimize the
effect of round-off!
Catastrophic Cancellation Errors
Evaluate c = a + b with
a = x.xxx . . . × 100 and
b = y.yyy . . . × 10−8
Consider c = a − b with
a = x.xxxxxxxxxxx1ssssss
b = x.xxxxxxxxxxx0tttttt
where x, y, s and t are decimal digits.
The digits sss . . . and ttt . . . are lost when a and b are
stored in double-precision, floating point format
Roots of Quadratic Equation
b b2 4ac
x
2a
( x x0 )( n 1) d ( n 1) f
f ( x ) Pn ( x ) Rn ( x ) where Rn ( x )
( n 1)! dx ( n 1) x
Big “O” Notation – Same Order of Magnitude
Truncation Error
Truncation error is the discrepancy introduced by the use
of an approximate expression in place of an exact
mathematical expression or formula. For example consider
the Taylor series expansion of the function ln(1+x)
(1)i 1 i
y ( x) ln(1 x) x
i 1 i
1 1 1 1 1
x x 2 x 3 x 4 x 5 x 6 ...
2 3 4 5 6
Some Advantages:
MATLAB Windows
Command History
Workspace Window
Scalar
Vector
3x4 Matrix
When you define variables in the command window, they are listed in
the workspace window
If you double click on any variable in the workspace window
MATLAB launches a document window containing the array
editor. You can edit variables in the array editor
The semicolon
suppresses the output
from each command
Figure Window
Editing Window