CHAP 03e
CHAP 03e
CHAP 03e
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
2
• Numerical methods yield approximate results that are close to the exact analytical
solution.
• How confident we are in our approximate result ? In other words,
“how much error is present in our calculation and is it tolerable?”
Significant Figures
• 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.
5.38 x 104 3
5.3800 x 104 5
Zeros are sometimes used to locate the decimal point not significant figures.
0.00001753 4
0.001753 4
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Identifying Significant Digits
http://en.wikipedia.org/wiki/Significant_figures
•All non-zero digits are considered significant. For example, 91 has two significant
figures, while 123.45 has five significant figures
•Leading zeros are not significant. Ex: 0.00052 has two significant figures.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Error Definitions
Approximate Error
• For numerical methods, the true value will be known only when we deal
with functions that can be solved analytically.
• In real world applications, we usually do not know the answer a priori.
Approximate error
Approximate Relative Error : a 100%
Approximation
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
5
If εs is chosen as:
s (0.5 10(2-n) )%
Then the result is correct to at least n significant figures (Scarborough 1966)
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
EXAMPLE 3.2: Maclaurin series expansion
2 3 n
x x x
e x 1 x ...
2 3! n!
Calculate e0.5 (= 1.648721…) up to 3 significant figures. During the calculation
process, compute the true and approximate percent relative errors at each step
= 3.1415926535….
• Discrepancy introduced by this omission of significant figures is called
round-off or chopping errors.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
8
Number
Representation
86409
in Base-10
173
in Base-2
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
9
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
10
exponent
m.be
mantissa
Base of the number system used
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
11
156.78 0.15678x103
(in a floating point base-10
system)
1
0.029411765 Suppose only 4
34
decimal places to be stored
0.0294100
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
12
• Due to Normalization, absolute value of m is limited:1
m 1
for base-10 system: 0.1 ≤ m < 1 b
for base-2 system: 0.5 ≤ m < 1
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
13
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
14
Your turn:
Problem Statement:
• What is the largest positive
floating point number that can
be represented using a 7-bit
word (3-bits reserved for
mantissa).
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
15
• Multiplication
• Overflow / Underflow
very small and very large numbers can not be represented using a fixed-
length mantissa/exponent representation, therefore overflow and underflow
can occur while doing arithmetic with these numbers.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
16
aspects of floating-point
representation that have significance
regarding computer round-off errors:
1. There Is a Limited Range of Quantities That May
Be Represented.
- Leads to Overflow Error
2. There Are Only a Finite Number of Quantities That
Can Be Represented within the range
Example:
π = 3.14159265358 . . . is to be stored on a base-10
number system carrying seven significant figures.
Solution:
One method of approximation would be to merely omit,
or “chop off,” the eighth and higher terms,
as in π = 3.141592,
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
17
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
18
Where
b is the number base and
t is the number of significant digits
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
19
Machine Epsilon
Problem Statement.
Determine the machine epsilon
and verify its effectiveness in
•characterizing the errors of the
number system on the adjacent
figure. Assume that chopping is
used.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
20
=0.25
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
21
Your turn:
Problem Statement 1: Problem Statement 2:
Determine the machine epsilon Determine the machine epsilon
and verify its effectiveness in and verify its effectiveness in
•characterizing the errors of the •characterizing the errors of the
number system on the adjacent number system on the adjacent
figure. Assume that chopping is figure. Assume that chopping is
used. used.
•01010112 •01100012
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
22
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
23
•[1 − (−1) = 2]
•0.4381 · 10−1 →0.004381 · 101
•Thus,
•Notice how the last two digits of the second number that were shifted to the right have essentially been
lost from the computation.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
24
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
25
chopped
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
26
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
27
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
28
2. 0.5612.102 + 0.5959.10-2
Subtractive Cancellation.
• This term refers to the round-off induced when
subtracting two nearly equal floating-point
numbers.
• effect of adding and subtracting large
numbers (each with some small error) and placing
great significance on the
differences>>>subtractive cancellation.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
30
One common instance where this can occur involves finding the roots
of a quadratic equation or parabola with the quadratic formula
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
31
Subtractive Cancellation
Problem Statement.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
32