Lecture Wk4 Ch3
Lecture Wk4 Ch3
Lecture Wk4 Ch3
Chapter 3 1
Recall the falling parachutist example
We determine the velocity of the falling
parachutist analytically & numerically
Discrepancy between the two method
Analytical:
exact
Numerical: approximation
Speedometer (3 significant
figures)
Odometer (7 significant
figures)
Chapter 3 4
Significant Figure Example: ZEROS
4.53 x 104 3
4.530 x 104 4 Scientific notation used to avoid confusion
4.5300 x 104 5
Zeros are sometimes used to locate the decimal point not significant figures
0.00001753 4
0.0001753 4 Zeros here are not significant figures
0.001753 4
The rules for identifying significant digits when writing or interpreting numbers are as follows:
• All non-zero digits are considered significant. For example, 91 has two significant digits (9 and 1), while 123.45 has
five significant digits (1, 2, 3, 4 and 5).
• Zeros appearing anywhere between two non-zero digits are significant. Example: 101.12 has five significant digits:
1, 0, 1, 1 and 2.
• Leading zeros are not significant. For example, 0.00052 has two significant digits: 5 and 2.
• Trailing zeros in a number decimal point are significant. For example, 12.2300 has six significant digits: 1, 2, 2, 3, 0
and 0. The number 0.000122300 still has only six significant digits (the zeros before the 1 are not significant). In
addition, 120.00 has five significant digits. This convention clarifies the precision of such numbers; for example, if a
result accurate to four decimal places (0.0001) is given as 12.23 then it might be understood that only two decimal
places of accuracy are available. Stating the result as 12.2300 makes clear that it is accurate to four decimal places.
• The significance of trailing zeros in a number not containing a decimal point can be ambiguous. For example, it may
not always be clear if a number like 1300 is accurate to the nearest unit (and just happens coincidentally to be an
exact multiple of a hundred) or if it is only shown to the nearest hundred due to rounding or uncertainty. Various
conventions exist to address this issue:
• A bar may be placed over the last significant digit; any trailing zeros following this are insignificant. For
example,1300 has three significant digits (and hence indicates that the number is accurate to the nearest ten).
• The last significant digit of a number may be underlined; for example, 2000 has two significant digits.
• A decimal point may be placed after the number; for example "100." indicates specifically that three significant
digits are meant.
• However, these conventions are not universally used, and it is often necessary to determine from context whether
such trailing zeros are intended to be significant. If all else fails, the level of rounding can be specified explicitly.
The abbreviation s.f. is sometimes used, for example "20 000 to 2 s.f." or "20 000 (2 sf)". Alternatively, the
uncertainty can be stated separately and explicitly, as in 20 000 ± 1%, so that significant-figures rules do not
apply.
Chapter 3 6
3.2 Accuracy and Precision
The errors associated with calculations and
measurements characterized by their
accuracy and precision
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). Magnitude of scatter.
Chapter 3 7
Bulls eye
represents
the truth
Bullet holes
represents
numerical
result
9
Chapter 3
The relationship between exact (true) and approximation
can be formulated as:
True error
true error
True fractional relative error
true value
true error
True percent relative error, t 100% (3.3)
true value
Chapter 3 10
Example 3.1:
Problem Statement. Suppose that you have the task of measuring the lengths of a bridge
and a rivet and come up with 9999 cm and 9 cm, respectively. If the true values are
10,000 cm and 10 cm, respectively, compute (a) the error and (b) the true percent relative
error for each case.
Solution.
(a) The error for measuring the bridge is [Eq. (3.2)]
𝐸𝑡 = 10,000 − 9999 = 1 cm
𝐸𝑡 = 10 − 9 = 1 cm
(b) The percent relative error for measuring the bridge is [Eq. (3.3)]
1
𝜀𝑡 = 100% = 0.01%
10.000
And for the rivet is
1
𝜀𝑡 = 100% = 10%
10
Thus, although both measurements have an error of 1 cm, the relative error for the
rivet is much greater. We would conclude that have done an adequate job of
measuring the bridge. Whereas our estimate for the rivet leaves something to be
desired.
Chapter 3 11
Chapter 3
13
Example 3.2 Error estimations for iterative methods
Chapter 3 14
Solution. First Eq. (3.7) can be employed to determine the error
criterion that ensures a results is correct to least three significant figures:
Thus after six terms are included, the approximate error falls below 𝜀𝑠 = 0.05%
and the computation is terminated. However, notice that, rather than three
significant figures, the result is accurate to five! This is because, for this case, both
Eqs (3.5) and (3.7) are conservative. That is they ensure that the result is at least as
good as they specify. Although as discussed in Chap. 6, this is not always the case
for Eq. (3.5) it is true most of the time. Chapter 3 16
3.4 Round-off Errors
Numbers such as p, e, or 7 cannot be expressed by a fixed number of
significant figures.
Computers use a base-2 representation, hence they cannot precisely
represent certain exact base-10 numbers.
Numerical round off errors directly to the manner in which numbers are
stored in a computer.
The unit to represent an information is referred as word.
Number systems: base-10, base-8, base-2.
Chapter 3 17
Figure 3.3 (a) Example Decimal number (b) Example of Binary number
Chapter 3 18
Integer representation in computer.
1 – represents negative
0 – represent positive
Figure 3.4 Representation of the decimal integer -173 on a 16-bits computer using
signed magnitude method.
Chapter 3 19
Example 3.3
Range of Integers.
Problem Statements. Determine the range of integers in base-10 that can
be represented on a 16-bit computer.
Solution. Of the 16 bits, the first bit holds the sign. The remaining 15
bits can hold binary numbers from 0 to 111111111111111. The upper
limit can be converted to a decimal integer as in
Example
156.78 0.15678x103 in a floating
point base-10 system
Chapter 3
21
Figure 3.5 The manner in which a floating-point number is stored
in a word
1 – represents negative
First bit – sign 0 – represent positive
Next series bits – signed exponent
Last bits - mantissa
Chapter 3 22
•Mantissa is normalized if it has leading zero digits.
•Example: 1/34=0.029411765…, if we want to store in a floating point base
-10 system that allowed only four decimal point.
1
0.029411765
34
0.0294100
Chapter 3 23
Normalization cause the absolute value of m is limited.
1
m 1
b
Therefore
for a base-10 system 0.1 ≤m<1
for a base-2 system 0.5 ≤m<1
Chapter 3 24
EXAMPLE 3.4
Hypothetical Set of Floating-Point Numbers
Problem Statement. Create a hypothetical floating-point number set for a
machine that stores information using 7-bit words. Employ the first bit
for the sign of the number, the next three for the sign and the magnitude
of the exponent, and the last three magnitude of the mantissa (Fig.3.6).
Magnitude
Sign of Sign of
of mantissa
number exponent
Magnitude
of exponent
Figure 3.6
The smallest possible positive floating-point number from Example 3.4
Chapter 3 25
Solution. The smallest possible positive number is depicted in Fig. 3.6.
The initial 0 indicates that quantity is positive. The 1 in the second place
designates that the exponent has a negative sign. The 1’s in the third and
fourth places give a maximum value to the exponent of
1 x 21 + 1 x 20 = 3
Therefore, the exponent will be -3. Finally, the mantissa is specified by 21 20 2-1 2-2 2-3
0 1 1 1 1 0 0
the 100 in the last three places. Which conforms to
1 x 2−1 + 0 x 2 −2 + 0 x 2−3 = 0.5 Magnitude of
Sign of Sign of
mantissa
number exponent
Although a smaller mantissa is possible (e.g., 000,001, 011), the value of Magnitude of
exponent
100 is used because of the limit imposed by normalization [Eq. (3.8)].
Thus, the smallest possible positive number for this system is +0.5 x 2 -3,
which is equal to 0.0625 in the base-10 system.
The next highest numbers are developed by increasing the mantissa, as
in
0111101 = (1 x 2-1 + 0 x 2-2 + 1 x 2-3) x 2-3 = (0.078125)10 0.015625
0111110 = (1 x 2-1 + 1 x 2-2 + 0 x 2-3) x 2-3 = (0.093750)10
0111111 = (1 x 2-1 + 1 x 2-2 + 1 x 2-3) x 2-3 = (0.109375)10 0.015625
Notice that the base-10 equivalents are spaced evenly with an interval of
0.015625.
At this point, to continue increasing, we must decrease the
exponent to 10, which gives a value of
1 x 2 1 + 0 x 20 = 2
Chapter 3 26
The mantissa is decreased back to its smallest value of 100. Therefore,
the next number is
Chapter 3 27
Figure 3.7 The hypothetical number system developed in Example 3.4.
Each value is indicated by a tick mark. Only the positive numbers are
shown. An identical set would also extend in the negative direction.
Chapter 3 28
From Figure 3.7, it can be seen that:
1. There is a limited range of quantities that may be represented – attempt to
employ number outside the acceptable range results in overflow error and
underflow error
2. There are only a finite number of quantities that can be represented
within the range. The degree of precision is limited
Example:
p=3.14159265358 to be stored on a base-10 system carrying 7
significant digits. We need to approximate it.
Chapter 3 29
Chapter 3 30
3. The interval between Numbers, x , increases as the Number Grows in
Magnitude. This allow floating-point representation to preserve
significant digits.
Quantization error proportional to the magnitude of the number.
For normalized floating-point numbers with chopping employed, the
proportionality is: x (3.9)
x
For normalized floating-point numbers with rounding employed, the
proportionality is: x (3.10)
x 2
1t
is machine epsilon, and b (3.11)
b is the number based and t is the number of significant digit in the
mantissa.
Chapter 3 31
EXAMPLE 3.5
Machine Epsilon
Problem Statement. Determine the machine epsilon and verify its
effectiveness in characterizing the errors of the number system from
Example 3.4. Assume that chopping is used.
Solution. The hypothetical floating-point system from Example 3.4.
amployed values of the base b= 2, and the number of mantissa bits t = 3.
Therefore, machine epsilon would be [Eq.(3.11)]
𝜀 = 21−3 = 0.25
Consequently, the relative quantizing error should be bounded by 0.25
for chopping. The largest relative should occur for those quantities that
fall just below the upper bound of the first interval between successive
equispaced numbers (Fig. 3.8). Those numbers falling in the succeeding
higher intervals would have the same value of Δx but a greater value of x
and, hence, would have a lower relative error. An example of a
maximum error would be a value falling just below the upper bound of
the interval between (0.1250000)10 and (0.156250)10. For this case, the
error would be less than
0.03125
= 0.25
0.125000
Figure 3.8 The largest quantizing error will occur for those values falling just below the
upper bound of the first of a series of equispaced intervals.
Chapter 3 32
Example 3.6: Machine Epsilon
Chapter 3 33
Chapter 3 34
Practical application of magnitude dependence of quantizing errors in
numerical methods:
1. Convergence quantities
2. Stopping mechanism for iterative process.
- To test whether the two quantities are equal, advisable to test whether
their difference is less than an acceptable tolerance
- Normalized should be employed mainly for numbers with large
magnitude.
- machine epsilon can be used in formulating stopping or convergence
criteria. This will ensure the program not dependent on the computer on
which they are implemented.
Chapter 3 35
3.4.2 Arithmetic Manipulations of Computer Number
Arithmetic manipulation cause round-off error.
Example;
A computer use 4 digit mantissa and a 1-digit exponent.
Chopping is used.
Adding: 0.1557.101+ 0.4381.10-1
0.4381.10-1=0.004381.101 (mantissa with the smallest
exponent is modified to match the exponents)
0.1557 .101
0.004381.101
0.160081.101 the result is chopped to 0.1600.101
The last two digits of the second number that were shifted to
the right have been lost from the computation.
Chapter 3 36
Subtraction (the process identical, but the
sign of subtrahend is reversed):
Example 1:
0.3641 .102
- 0.2686 .102
Chapter 3 38
Week 3 Exercise 1
Estimate the value of e-5 that make absolute value of approximate error (ea)
falls below a pre-specified error criterion es confirming to 5 significant figures.
Calculate true error and estimated error for each considered term.
Chapter 3 39
Week 3 Exercise 2
Chapter 3 40