Lecture 2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

Numerical Methods

CSE 2105
Lecture 2
Chapter 4 : APPROXIMATIONS AND ERRORS IN
COMPUTING
2

 Introduction
 Significant Digits
 Inherent Errors
 Numerical Errors
 Absolute and Relative Errors
Introduction
3

 Approximations and errors are integral part of


numerical methods. Errors can come in a variety of
forms and sizes.
 By careful analysis and proper design and
implementation of algorithm, we can restrict their
effect quite significantly.
 Prior to using the numerical methods it is essential
to know :
 how errors arise.
 how they grow during the numerical computations.
 how they affect the accuracy of a solution.
Significant Digits
4

 Π =3.1415926535897032384626…..
 2/7 = 0.285714285714…..

Suppose we write Π as 3.14159 and 2/7 as 0.285714.


Then the number contains six significant digits.

 “good to four digits” means that the number has


four significant digits.
Notion of Significant Digits
5

 All non-zero digits are considered significant. For example,


91 has two significant figures (9 and 1), while 123.45 has
five significant figures (1, 2, 3, 4 and 5).
 Zeros appearing anywhere between two non-zero digits are
significant. Example: 101.1203 has seven significant figures:
1, 0, 1, 1, 2, 0 and 3.
 Trailing zeros in a number containing a decimal point are
significant. For example, 12.2300 has six significant
figures: 1, 2, 2, 3, 0 and 0. The number 0.000122300 still
has only six significant figures (the zeros before the 1 are
not significant).
 Zeros between the decimal point and preceding a non zero
digit are not significant. Example : 0.0001234 (1234 x 10-7)
the following number have four significant digits.
Accuracy & Precision
6
 Accuracy : Accuracy is
how close you are to the
true value.
 Precision : Precision is
how close two or more
measurements are to
each other.
Inherent Errors
7

 Inherent Errors are those that are present in the data


supplied to the model. (Known as input errors).
 Contain two components :
 Data Errors
 Conversion Errors
 Data Errors : arises when data for a problem are
limited accuracy and precision.
 Conversion Errors : arises due to the limitations
of the computer to store the data exactly.
Numerical Errors
8

 Numerical errors are introduced during the process


of implementation of a numerical method. They
come in two forms :
 Roundoff Errors
 Truncation Errors
Roundoff Errors
9

 Roundoff Errors occur when a fixed number of digits


are used to represent exact numbers.
 Rounding a number can be done in two ways :
 Chopping
 Symmetric Rounding
Chopping
10

 In Chopping, the extra digits are dropped. This is


called truncating the number.
 True x = (fx +gx x 10-d )10E
=(fx x 10E) + (gx x 10E-d)
= approximate x + error (Where, 0<gx <1)
Where, fx = mantissa
d = length of the mantissa permitted
E = exponent
In Chopping, gx is ignored entirely.
Symmetric Rounding
11

 In symmetric roundoff method, the last retained


significant digit is “rounded up” by 1 if the first
discarded digit is larger or equal to 5.
 42.7893 would become 42.79 & 76.5432 would
become 76.54.
 Approximate x =(fx x 10E).
 Error = (gx - 1)x 10E-d Where, gx > 0.5
Example
12

 Find the roundoff error in storing the number 752.6835


using a four digit mantissa.
 Solution : True x =0.7526835 x 103
= 0.7526 x 103 + 0.835 x 103-4
In Chopping Method,
Approximate x = 0.7526 x 103
Error = 0.0835
In Symmetric Method,
Approximate x = 0.7527 x 103
Error = (gx - 1)x 10-1
= -0.165 x 10-1
= -0.0165
Blunders
13

 Blunders are errors that are caused due to human


imperfection.
 As the name indicates, such errors may cause a very
serious disaster in the result.
 Since these errors are due to human mistakes, it
should be possible to avoid them by acquiring a
sound knowledge about the numerical process.
Blunders
14

 Some common types of human errors :


 Lack of understanding the problem.

 Wrong assumption.

 Overlooking of some basic assumptions.

 Errors in deriving the mathematical equation.

 Selecting a wrong numerical method.

 Selecting a wrong algorithm.

 Making mistakes in the computer program.

 Mistakes in data input.

 Wrong guessing of initial values.


Absolute and Relative Errors
15

 True value xt = Approximate value xa + Error.


 Error = xt - xa .
 Absolute error, ea = | xt - xa |
 “Normalized” absolute error is called Relative error.
 er =(absolute error) / |true value|.
 er = | xt - xa | / | xt |.
Example
16

 Problem : A civil engineer has measured the height of a 10 floor


building as 2950cm and the working height of each beam as 35cm
while the true values are 2945cm and 30cm, respectively. Compare
their absolute and true percent relative errors.
 Solution : Absolute error in measuring the height of the building is
e1 = 2950 – 2945 = 5 cm
The true percent relative error is,
er,1 = 5/2945 = 0.0017 = 0.17 %
Absolute error in measuring the height of the beam is
e2 = 35 -30 = 5 cm
The true percent relative error is,
er,1 = 5/30 = 0.17 = 17 %
Homework
17

 Problem : Suppose that you have the task of


measuring the lengths of a bridge and a rivet and
come up with 9999 and 99 cm, respectively. If the
true values are 10000 and 100 cm, respectively,
compute (a) the true error and (b) the true percent
relative error for each case.
 Truncation error
(Adding new slide in this existing slide for solving
these two. I will take feedback in the next class)
18

THANK YOU

You might also like