Lesson 1 PDF
Lesson 1 PDF
Lesson 1 PDF
Lesson 1
Approximation and Rounding errors
Introduction
This module is all about the approximations and rounding errors that is being
used for numerical analysis of equations and formulas.
Overview
Numerical methods must be sufficiently exact and precise to satisfy the
requirements of electrical engineering problems may it be theoretical (Ohm’s
law, Kirchoff’s Voltage and Current Law, Fault Analysis) and practical (sizing
and length of wire estimation, selecting of optimal brand of devices based on
cost). Thus, it is important to differentiate the terminologies and its
application first before going into the numerical analysis.
Objectives
After successful completion of this module, you should be able to:
• Differentiate between accuracy, precision and bias
• Define the significant figures
• Determine different error types
• Conduct an error analysis for solutions and answers
Approximations and Rounding Errors
4
Approximations and Rounding Errors
5
Approximations and Rounding Errors
6
Approximations and Rounding Errors
A is successful.
B : holes agree with each other (consistency or precision), but they deviate
considerably from where the shooter was aiming (no correctness)
B lacks correctness (exactness).
C lacks both correctness and consistency.
D lacks consistency (precision).
The shooters of targets C and D were imprecise. 3- 7
Summary of Bias, Precision and Accuracy
Non-numerical errors:
(1) modeling errors: generated by assumptions and
limitations.
(2) blunders and mistakes: human errors
(3) uncertainty in information and data
3- 9
Numerical errors:
(1) round-off errors: due to a limited number of
significant digits
(2) truncation errors: due to the truncated terms
e.g. infinite Taylor series
(3) propagation errors: due to a sequence of
operations. It can be reduced with a good
computational order. e.g.
In summing several values, we can rank the
values in ascending order before performing
the summation.
(4) mathematical-approximation errors:
e.g. To use a linear model for representing a
nonlinear expression.
3- 10
Measurement and Truncation Errors
error(e): the difference between the computed (xc) and true (xt) values of a
number x
e = x c − xt
x c − xt e
er = =
xt xt
3- 11
Example: Truncation Error in Atomic Weight
The weight of oxygen is 15.9994. If we
round the atomic weight of oxygen to 16,
the error is
e = 16 - 15.9994 - 0.0006
The relative true error:
0.0006
er = = 0.4 10−4
15.9994
3- 12
Approximations and Rounding Errors
Error definitions:
True value = approximation + absolute error.
Absolute error = true value - approximation .
Relative error = absolute error / true value .
𝑎𝑏𝑠𝑜𝑙𝑢𝑡𝑒 𝑒𝑟𝑟𝑜𝑟
𝜀𝑡 = 𝑥100%
𝑡𝑟𝑢𝑒𝑣𝑎𝑙𝑢𝑒
In real cases not always one can know the true value, thus:
𝑎𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑒 𝑒𝑟𝑟𝑜𝑟
𝜀𝑎 = 𝑥 100%
𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑒 𝑣𝑎𝑙𝑢𝑒
𝑥 3 − 3𝑥 2 − 6𝑥 + 8 = 0
8
x = 3x + 6 −
x
The initial estimate x0 = 2
8
x1 = 3x0 + 6 − = 2.828427
x0
error:
See the table on the next page.
e = x1 − x0 = 0.828427
3- 14
Table: Error Analysis with xt =4
Trail i xi ei xt − xi
0 2.000000 - 2.000000
1 2.828427 0.828427 1.171573
2 3.414214 0.582786 0.585786
3 3.728203 0.313989 0.271797
4 3.877989 0.149787 0.122011
5 3.946016 0.068027 0.053984
6 3.976265 0.030249 0.023735
7 3.989594 0.013328 0.010406
8 3.995443 0.005849 0.004557
9 3.998005 00002563 0.001995
3- 15
b
1
Example: dx
x
a
analytical solution: ln(b) – ln(a)
numerical solution e. g., Trapezoidal Rule
Error Analysis
(a) identify the possible sources of error
(b) estimate the magnitude of the error
(c) determine how to minimize and control error
16
Approximations and Rounding Errors
Thus, the stopping criterium of a numerical method can be:
a s
s = prefixed percent tolerance
17
Approximations and Rounding Errors
Numerical systems:
A numerical system is a 104 103 102 101 100
convention to represent 8 6 4 0 9
quantities. Since we have
9x 1= 9
10 fingers in our hands, the 0x 10 = 0
4 x 100 = 400
most popular numerical a)
6 x 1000 = 6000
8 x 10000 = 80000
system has basis 10. It uses 86409
10 different digits. 27 26 25 24 23 22 21 20
1 0 1 0 1 1 0 1
1x 1= 1
However, computers, due 0x 2= 0
1x 4= 4
to the memory structure, 1x 8= 8
0 x 16 = 16
can only store two digits: 0 b)
1 x 32 = 32
0 x 64 = 64
and 1. Thus, they use the 1 x 128 = 128
173
binary system of numeric
representation.
18
Approximations and Rounding Errors
Unfortunately, computers introduce errors in the calculations.
However, since many engineering problems have not analytical
solution, we are forced to use numerical methods
(approximations). The only option we have is to accept the
error and try to reduce it up to a tolerable level.
The only way of minimizing the errors is by knowing and
understanding why they occur and how we can diminish them.
The most frequent errors are:
Rounding errors, due to the fact that computers can work
only with a finite representation of numbers.
Truncation errors, due to differences between the exact
and the approximate (numeric) formulations of the
mathematical problem being dealt with.
Before analyzing each one of them, we will see two important
concepts on the computer representation of numbers.
19
Approximations and Rounding Errors
Significant figures of a number:
= 3.14159265...
17 = 4.123105...
20
Significant Figures
If 46.23 is exact to the four digits shown, it has
four significant digits (The last digit is
imprecise). The error is no more than 0.005.
The digits from 1 to 9 are always significant,
with zero being significant where it is not being
used to set the position of the decimal point.
2410, 2.41, 0.00241: three significant digits
(0 in 2410 is only used to set the decimal place.)
Scientific notation can be used to avoid
confusion:
2.41×103: three significant digits
2.410×103: four significant digits
3- 21
Computation : Any mathematical operation using an
imprecise digit is imprecise.
Example: 3 significant digits (underline indicates an
imprecise digit.)
significant digit.
Round-off Errors
Background: How are numbers stored in a computer?
(anan-1...a1a0.b1b2..bk..)q
(anan-1...a1a0.b1b2..bk..)q =anqn+an-1qn-1+...+a1q+a0q0+b1q-1+b2q-2+...
Example:
(1011.01)2=1x23+0x22+1x2+1x20+0x2-1+1x2-2=11.25
25
Round-off Errors
Conversion from base 10 to base q.
Example:
(26.1)10=(11010.00011)2
26
Approximations and Rounding Errors
28
Approximations and Rounding Errors
IEEE-floating point formats: there are two types of “precision” (simple and double). They differ in
the number of digits available for storing the numbers:
Simple precision (32 bits): 1 bit for the sign, 8 bits for the exponent, 23 bits for the mantissa.
Double precision (64 bits, two words of 32 bits): 1 bit for the sign, 11 bits for the exponent, 52
bits for the mantissa.
The number of bits for the exponent and the mantissa determine the “underflow” and
“overflow” numbers.
29
Round-off Error due to Arithmetic Operations
Examples:
30
Mathematical Models
Comparing solutions:
Approximate Approximat
Numerical solution,
t=2seg
60
t(sec) Exact
(t=2s.) (t=1s.)
0 0 0 0 50
V (m/sec)
40
4 27,798 32,037357 29,697439 Exact
6 35,678 39,896213 37,615198 solution
30
8 41,137 44,870026 42,893056
10 44,919 48,017917 46,411195 20
Numerical solution,
12 47,539 50,010194 48,756333 t=1seg
14 49,353 51,271092 50,319566 10
31