Chapter2Numerical
Download
Report
Transcript Chapter2Numerical
Chapter 2
Errors in Numerical Methods
and Their Impacts
Objectives
•Know the difference between accuracy&precision
•Understand round-off error
•Understand approximation error and know how to
apply
Content
•
•
•
•
•
•
Introduction
Errors
Round-off errors
Approximate errror
Total errors
Conclusion
Introduction
• Why we need to know ?
• Computers are great tools, however, without
fundamental understanding of engineering
problems, they will be useless.
Errors
• We ask for numerical methods since we cannot
get exact solution !!
• Numerical methods only provide approximate
results, not exact ones.
• So how we confident our results obtained from
numerical methods ????
See in next slide how can we cope this with?
Errors (cont’d)
• Accuracy. How close is a computed or measured
value to the true value
• Precision (or reproducibility). How close is a
computed or measured value to previously
computed or measured values.
• Inaccuracy (or bias). A systematic deviation from
the actual value.
• Imprecision (or uncertainty or variance).
Magnitude of scatter.
Errors (cont’d)
Errors (cont’d)
• Number of “significant figures” indicates precision. Significant
digits of a number are those that can be used with confidence,
e.g., the number of certain digits plus one estimated digit.
53,800 How many significant figures?
5.38 x 104
5.380 x 104
5.380 x 104
3
4
5
Zeros are sometimes used to locate the decimal point not
significant figures.
0.00001753
0.0001753
0.001753
4
4
4
Errors (cont’d)
Error Definitions
True Value = Approximation + Error
Et = True value – Approximation (+/-)
True error
MATLAB Example
true error
True fractional relative error
true value
true error
True percent relative error, t
100%
true value
Errors (cont’d)
What u can see is we can’t estimate the true error
for
all
cases
!!
(why
?)
So we use the following error definition instead.
Approximation error …
Approximate error
a
100%
Approximation
Errors (cont’d)
Apply approximation error to numerical approach
(iterative)
a Current approximation - Previous approximation 100%
Current approximation
(+ / -)
Define criteria : s (0.5 10 (2-n) )%
Compute until
a s
Meaning that the result
is correct at least n
significant figures
Errors (cont’d)
DIY: MATLAB (Parachutist problem)
From your previous assignment, compare the approximation errors
at t = 1,2,..,12 seconds for two cases, Δt = 0.5 and 0.1 respectively.
Crticize why the approximation errors from these two cases are
different !!
Round-off …
• Why round-off errors occur ?
1) There are numbers that can’t be expressed by a
fixed number of significant figures
2) Base-2 number can’t precisely represent base-10
number (completely).
3) Fraction number in computer is represent using a
floating point form, e.g.
Integer part
m.be
mantissa
where
exponent
Base of the number system
used
1
m 1
b
Round-off … (cont’d)
How floating numbers ‘re stored in a computer ??
Integer part
m.be
mantissa
11 bits
exponent
Base of the number system
used
52 bits
Round-off … (cont’d)
How floating numbers ‘re stored in a computer
(base-2 number) ??
Round-off … (cont’d)
Examples: 156.78 0.15678x103
Suppose only 4 decimal places to be stored
0.1567x103
0.1568x103
Rounding/Chopping
Now u can see how the round-off error occurs due to
the limited room for mantissa !!!!
Round-off … (cont’d)
Examples: MATLAB
Double precision case
Type format long
a=0.1+0.2-0.3 what you expect
Now try more example:
learn
round(0.5)
Type
round(0.75*0.3/0.01) what you expect
Approxi …
Example:
To get the cos(x) for small x:
x2 x4 x6
cos x 1
2! 4! 6!
If x=0.5
cos(0.5) =1-0.125+0.0026041-0.0000127+ …
=0.877582
From the supporting theory, for this series, the error is
no greater than the first omitted term.
x8
8!
for
x 0.5 0.0000001
Approxi …
Using Taylor’s series approximation
f
f ( xi 1 ) f ( xi ) f ( xi )( xi 1 xi )
( xi 1 xi ) 2
2!
f (n)
( xi 1 xi ) n Rn
n!
f
( ) ( n1)
Rn
h
(n 1)!
( n 1)
Approxi …
Example: f(x) = -0.1x4-0.15x3-0.5x2-0.25x+1.2
(estimate this function at x = 1 with h = 1, given that
x(0)=1.2)
Try to derive your own and
also write a program to show
for number of order
n =1,2,3,…,5
Approxi …
U can use Taylor series to avoid the round off errors
For example: try to calculate
ex-1
X
at x = 0
Total …
There is a trade-off
Others…
Blunders
Human mistakes
Model errors
Incomplete mathematical
model
Data uncertainty
Bias, variance from measurements