GENG4405 Numerical Methods and Modelling
Arcady Dyskin
Topics
! Computer arithmetic. Truncation and roundoff errors ! Matrices ! Linear equations. Methods of solution ! Ill-conditioned matrices ! Interpolation and curve fitting
GENG4405
Slide 2
Errors
! Types of errors ! Computer arithmetic. Truncation and roundoff errors ! Example. Numerical differentiation ! Example. Unstable algorithm
Absolute error Relative error
" r = ra ! r
!r !r #r = " r ra
Here r is the exact value, ra is an approximate value
GENG4405 Slide 3
Points to learn
! ! ! ! ! Types of error Precision Catastrophic cancellation Numerical differentiation Sensitivity of numerical differentiation to errors ! How to choose the increment - Later ! Unstable algorithms
GENG4405 Slide 4
Example. Compression of a layered sample Uniaxial loading of
layered material (glass layers)
80 70 60 50 40 30 20 10 0 0 0.002 0.004 strain 0.006 0.008 stress vs strain - glass1
stress (MPa)
Stress-strain curve (courtesy Glen Snowen)
GENG4405 Slide 5
Tangential modulus
d# "# E (! ) = $ d! "!
E(!) [MPa]
80000 70000 60000 50000 40000 30000 20000 10000 0 -10000 -20000
GENG4405
10
20
30
40
50
60
70
80
! [10-6]
Slide 6
Types and sources of errors
! Human/Faulty equipment errors (can be corrected)
! Checks and verifications
! Errors of measurements
! Systematic
! Calibration
! Random
! Repeated measurements ! Statistical treatment
! Truncation/Roundoff errors
! Computer arithmetic ! Small ! Double precision computations
GENG4405 Slide 7
Computer arithmetic. Truncation and roundoff errors
The floating-point arithmetic Real numbers are usually represented in computers by floating-point numbers F. They are characterised by: the number base ", the precision t and the exponent range [L, U].
* d1 d 2 dt ' e x = ( ( # + # 2 + ! + #t % % $ # , 0 ! d i ! # " 1, i = 1,, t , L ! e ! U ) &
If d1#0 (for x#0), then the floating-point number system F is normalised. The integer e is called the exponent
f = d1 ! + + d t !t
is the mantissa (fraction)
GENG4405 8
Precision
PC
Real (real*4) mode Double precision (real*8) mode,
! = 2, t = 24, U = 123, L = "123
! = 2 , t = 53, U = 1023,
L = "1023
In decimal system it would approximately correspond to
Real (real*4) mode Double precision (real*8) mode,
! = 10, t = 7 , U = 38, L = "38 ! = 10, t = 16, U = 308, L = "308
Any real number x is replaced in a computer by the closest number, fl(x), from F
The relative error in rounding (x#0):
fl ( x) ! x 1 1!t # " x 2
GENG4405 Slide 9
Influence of small errors
! Catastrophic cancellation
! Loss of accuracy due to subtraction of close numbers
0.123456-0.123455=0.000001 (only one significant digit left)
! Numerical differentiation
! Unstable algorithms ! Sensitive models
! Ill conditioned systems (next two chapters)
GENG4405
Slide 10
Unstable algorithms. Example: Moment of inertia
Non-homogeneous material
1
I y = ! x 2"( x)dx
0
Relative density distribution y 1m
" ( x) = e x!1
I y = " x e dx ! E2
0
2 x #1
1m
x
GENG4405 Slide 11
Moments of inertia for different shapes y
1m
1
I y = " x 3e x #1dx ! E3
0
1m y 1m
I y = " x 4e x #1dx ! E4
0
1m
x
GENG4405 Slide 12
General case
y 1m
En =
1m x
"
0
x n e x!1 dx > 0
Integration by parts gives the following direct recurrent formula
1 En = 1 " nEn "1 , E0 = 1 " ! 0.632120 e
GENG4405 Slide 13
Calculations
n
2 3 4 5 6 7 8 9 Recurrent formula 0.264242 0.207274 0.170904 0.14548 0.12712 0.11016 0.11872 -0.06848 Exact 0.264241 0.207277 0.170893 0.14533 0.126802 0.112384 0.100932 0.091612
GENG4405
Computer with "=10 and t=6
Slide 14
Analysis of recurrent computation of inertia moments
Initial roundoff error
$ # 0.368 "10 !6
E0 = 0.63212 + ! E1 = 0.367879 # ! E2 = 1 # 2 " 0.367879 + 2 " ! = 0.264242 + 2 " !
En = 1 ! nEn!1
E3 = 1 # 3 " 0.264242 # 3 " 2 " ! = 0.207274 # 6 " ! ! E9 = E9exact # 9!"! = E9exact # 362880 " !
The error of 9-th step is 0.133>E9exact
This algorithm is unstable error accumulation
GENG4405 Slide 15
Stable algorithm
1 ! Note En = " x n e x!1 dx < " x n dx = n +1 0 0 ! Inverse recurrent formula 1 ! En En!1 = n ! Error is damped ! Start with E20 ! 0 ! This approximation has an error not greater than 1/21. ! When the 9th term is approached, the initial error is divided by 20 ! 19 ! ! 10 = 362880 "7 ! It becomes less than 1.3 ! 10 ! The obtained result is E9 ! 0.09161123 ! The relative error is about 1.4 ! 10 "6
GENG4405 16
Summary
! Errors
! Measurements ! Computational
! Computer arithmetic ! Truncation and roundoff errors ! Controlled by precision - formula
! Catastrophic cancellation
! Subtraction of close numbers
! Unstable algorithms
! Simple methods could lead to catastrophic accumulation of errors
GENG4405
Slide 17