Module 2 Presentation - Approximations and Errors
Module 2 Presentation - Approximations and Errors
APPROXIMATIONS
AND ERRORS
Learning Objectives:
At the end of the lesson, you as a future Engineer,
are expected to:
• Differentiate and calculate errors.
• Understand the difference between accuracy
and precision
• Learn how to represent numbers in a floating
point form
• Convert different number systems
• Differentiate non-linear transcendental and
polynomial functions.
• Review about the Taylor series
Topics:
A. Numbers and their Accuracy
1. Floating Point Representation
B. Significant Figures
C. Accuracy and Precision
D. Error Definitions
1. Measuring Errors
2. Sources of Errors
3. Propagation Errors
E. Binary Representation of Numbers
F. Taylor Series Revisited
INTRODUCTION
Numerical methods provide solutions to problems that are
based on approximation and along with that, error is also
generated.
326= 326
FLOATING POINT REPRESENTATION
A typical computer uses the so-called floating
point representation for real numbers. This
consists of a certain number of binary digits or bits
divided into three parts namely:
Ø a single digit for the sign (which may be positive
or negative),
Ø a fixed number of digits representing the
fractional or decimal part called the mantissa,
and
Ø another fixed number of digits to represent the
exponent or characteristic.
Common Number Systems
ØDecimal - Base 10 (0-9)
ØBinary – Base 2 (0,1)
ØOctal – Base 8 (0-7)
ØHexadecimal – Base 16 (0-F)
Figure 1. The manner in which a floating point
number is stored in a word.
The general form of the floating point representation
for real numbers is:
±0.a1a2…ak x bm
Where:
- k is the maximum number of digits allowed in the
mantissa,
- b is the base of the representation and
- m is the exponent.
Note: The digit a1 in the mantissa is not allowed to be zero,
except for the case when the number being represented is 0.
Example 1:
325.687
+0.325687 x 103.
Rounding Off Numbers in Floating-Point
Form
There are two ways of rounding off these
numbers which are employed by the
computer.
A. Truncation or Chopping
B. Symmetric Rounding Off
TRUNCATION OR CHOPPING
In this method, if the mantissa
contains m digits, then the first m
significant digits of the number are
retained, while the remaining digits
are chopped off.
Example:
Round off the number 152.6893156 to five
significant digits and express the result in floating
point form using Truncation or chopping.
Solution:
The floating point representation of 152.6893156
is +0.1526893156 x 103, hence its mantissa is
0.1526893156.
By truncation, we retain only the first m=5
significant digits of mantissa. Thus, we obtain
0.15268 x 103
SYMMETRIC ROUNDING OFF
It is carried out by first adding the quantity
(b/2) x b –m-1
to the mantissa before truncation is done.
This method is similar to the rounding off that
we do when we perform manual calculations in
base ten, wherein we add 1 to the last digit that
we retain if the first digit to be dropped off is at
least 5 ( in this case, we have b=10, so that
b/2=5).
Example:
Round off the number 152.6893156 to five significant
digits and express the result in floating point form
using Symmetric Rounding Off.
Solution:
The floating point representation = +0.1526893156 x 103
By using symmetric rounding off, we first compute:
𝒃 𝟏𝟎
xb –m-1 = x 10-6 = 0.000005
𝟐 𝟐
Add this quantity to the mantissa,
0.1526893156 + 0.000005 = 0. 1526943156,
And then retain only the first m=5 significant digits,
yielding 0.15269 x 103
SEATWORK
Express each of the following numbers in floating
point from with the given length m of the
mantissa, and then perform (1) symmetric
rounding off and (2) truncation or chopping. The
indicated subscript represents the base.
a. 34516.8312, m=6
b. 43301102142115, m=7
c. .00004434210621317, m=8
d. 12214.100235, m=5
Answer:
a. 34516.8312, m= 6
Floating Point
+0.345168312x105
Truncation
0.345168x105
Symmetric
(10/2)x10-6-1=5x10-7 =0.0000005
0.345168312+0.0000005
=0.345168812
0.345168x105
Answer:
b. 43301102142115, m= 7
Floating Point
+0. 4330110214211x513
Truncation
0. 4330110x513
Symmetric
(5/2)x5-7-1=2.5x5-8 =0.000000025
0. 4330110214211+0.000000025
=0.433011046421
=0. 4330110x513
Answer:
d. 12214.100235, m= 5
Floating Point
+0. 1221410023x55
Truncation
+0. 12214x55
Symmetric
(5/2)x5-5-1=2.5x5-6 =0.0000025
0. 1221410023+0.0000025
=0. 122143523
=+ 0. 12214x55
Significant Figures
The significant digits of a number are those
that can be used with confidence.
and ,
a.)
For x=2 and h=0.3
Note:
= 10.265
SOLUTION, con’t.
For
and ,
and ,
and ,
APPROXIMATE ERROR
When we are solving a problem numerically,
we will only have access to approximate values.
We need to know how to quantify error for
such cases.
Approximate error is denoted by Ea and is
defined as the difference between the present
approximation and previous approximation.
Approximate Error = Present Approximation – Previous Approximation
EXAMPLE
The derivative of a function f(x) at a particular
value of can be approximately calculated by
c
SOLUTION:
a) The approximate expression for the
derivative of a function is
= 10.265
SOLUTION:
b) Repeat the procedure of part (a) with h=0.15
Note:
= 9.8799
SOLUTION:
c) So the approximate Error, Ea is
Ea = Present Approximation – Previous Approximation
= 9.8799 – 10.265
= - 0.38474
RELATIVE APPROXIMATE ERROR
c) So the approximate Error, Ea is
Ꜫa = Present Approximation – Previous Approximation
Present Approximation
=| 9.8799 – 10.265 x100 |
9.8799
= 3.897812731%
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 : ea = ´100%
Approximation
Iterative approaches (e.g. Newton’s method)
(Current Approx.) - (Previous Approx.)
Approx. Relative Error : e a = ´100%
CurrentApprox.
Computations are repeated until stopping criterion is satisfied
If εs is chosen as:
e s = (0.5 ´ 10 (2 -n) )%
Then the result is correct to at least n significant figures (Scarborough 1966)
48
ROUND OFF ERROR
A computer can only represent a number
approximately. For example, a number like
may be represented as 0.333333 on a
PC. Then the round off error in this case is
List the powers of two in a "base 2 table" from right to left. Start
at 20, evaluating it as "1". Increment the exponent by one for
each power. Make the list up until you've reached a number very
near the decimal system number you're starting with. For this
example, let's convert the decimal number 15610 to binary.
BINARY
REPRESENTATION, con’t.
Descending Powers of Two Subtraction
BINARY
REPRESENTATION, con’t.
Descending Powers of Two Subtraction
2. Look for the greatest power of 2.
Choose the biggest number that will fit into the number you are
converting. 128 is the greatest power of two that will fit into 156,
so write a 1 beneath this box in your chart for the leftmost binary
digit. Then, subtract 128 from your initial number. You now have
28.
BINARY
REPRESENTATION, con’t.
Descending Powers of Two Subtraction
BINARY
REPRESENTATION, con’t.
Descending Powers of Two Subtraction
3. Move to the next lower power of two.
Using your new number (28), move down the chart marking how
many times each power of 2 can fit into your dividend. 64 does
not go into 28, so write a 0 beneath that box for the next binary
digit to the right. Continue until you reach a number that can go
into 28.
BINARY
REPRESENTATION, con’t.
Descending Powers of Two Subtraction
BINARY
REPRESENTATION, con’t.
Descending Powers of Two Subtraction
4. Subtract each successive number that can fit, and mark it
with a 1.
16 can fit into 28, so you will write a 1 beneath its box and
subtract 16 from 28. You now have 12. 8 does go into 12, so
write a 1 beneath 8's box and subtract it from 12. You now
have 4.
BINARY
REPRESENTATION, con’t.
Descending Powers of Two Subtraction
BINARY
REPRESENTATION, con’t.
Descending Powers of Two Subtraction
5. Continue until you reach the end of your chart.
86409
in Base-10
173
in Base-2
71
The representation of -173 on a 16-bit computer
using the signed magnitude method
72
Common Arithmetic Operations
ADDITION:
0.1557 · 101 + 0.4381 · 10−1
• [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.
73
Common Arithmetic
Operations
• SUBTRACTION:
▫ sign of the subtrahend is reversed.
▫ Example>>>subtract 26.86 from 36.41
The loss of significance during
the subtraction of nearly
equal numbers is among the
greatest source of round-off
error in numerical methods.
▫ the result is not normalized, and so shift the decimal one place to
the right to give 0.9550 · 10 = 9.550
1
74
Common Arithmetic
Operations
• MULTIPLICATION:
– Example:
chopped
75
Common Arithmetic
Operations
• DIVISION:
– Division is performed in a similar manner, but the
mantissas are divided and the exponents are
subtracted. Then the results are normalized and
chopped.
76
Adding a Large and a Small
Number.
• Suppose we add a small number, 0.0010, to a large
number, 4000, using a hypothetical computer with
the 4-digit mantissa and the 1-digit exponent. We
modify the smaller number so that its exponent
matches the larger,
77
SEATWORK 3
NORMALIZE YOUR ANSWER
Convert the following:
1. 123510= __________2 1. 1.0678.100 + 0.0986.10-2
2. 1100111012=_________10 2. 0.5612.102 + 0.5959.10-2
3. 101010111112=__________10 3. Subtract 0.5612+ 1.5959
4. 342010=__________________2 4. Subtract 1.0008.10-2+ 0.0341.101
5. 1010111111002=_____________10 5. Multiply 1.5612 and 0.0219
6. Multiply 0.5612.102 + 0.5959.10-2
Use Maclaurin Series to solve for the
Et and Ea. 7. Add 0.5612.104 + 0.00 5959.10-2
Find the value of e0.75 using the first 7
terms of the Maclaurin series
expansion.
78
Thank you for
listening!!!
Prepared by:
Engr. Michael L.de Vera