Chapter 2
Approximations and Errors in
Numerical Analysis
Dr. Ammar Isam Edress
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
What Is Numerical Analysis?
• The objective of numerical analysis is to solve complex
numerical problems using only the simple operations of
arithmetic, to develop and evaluate methods for computing
numerical results from given data. The methods of computation
are called algorithms.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
ALGORITHMS
• Our efforts will be focused on the search for algorithms. For
some problems no satisfactory algorithm has yet been found,
while for others there are several and we must choose among
them.
• There are various reasons for choosing one algorithm over
another, two obvious criteria being speed and accuracy.
Speed is clearly an advantage, though for problems of modest
size this advantage is almost eliminated by the power of the
computer.
• For larger scale problems speed is still a major factor, and a
slow algorithm may have to be rejected as impractical.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Exercise
Find the answer for the following to four decimal places.
For n = 1 to 5
1
𝑥1 = 0.5 𝑥𝑛+1 = 𝑥𝑛 −
2𝑥𝑛
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Exercise
Find the square root of 2 to four decimal places. More than one
algorithm, using only the four basic operations of arithmetic, exists.
The favourite is without much doubt
𝑥1 = 1 1 2
𝑥𝑛+1 = (𝑥𝑛 + )
2 𝑥𝑛
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
What Is Numerical Analysis?
ERROR
• The numerical optimist asks how accurate are the computed results ?
• The numerical pessimist asks how much error has been introduced ?
The two questions are, of course, one and the same.
• Only rarely will the given data be exact, since it often originates in
measurement processes. So there is probably error in the input
information, and usually the algorithm itself introduces error,
perhaps unavoidable roundoffs.
• The output information will then contain error from both of these
sources.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Precision and Accuracy
Two terms are commonly associated with any discussion of error:
"precision" and "accuracy".
Precision refers to the reproducibility of a measurement while accuracy
is a measure of the closeness to true value. The concepts of precision
and accuracy are demonstrated by the series of targets below.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Precision and Accuracy
If the centre of the target is the "true value", then
• A is neither precise nor accurate.
• Target B is precise (reproducible) but not accurate.
• The average of target C's marks give an accurate result but precision
is poor.
• Target D demonstrates both precision and accuracy - which is the
goal in lab.
Fig. 1
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
• Accuracy. How close is a computed or measured
value to the true value
• Precision 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.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Fig. 2
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Summary
All experiments, no matter how well-planned and executed, have
some degree of error or uncertainty. In general chemistry lab, you
should learn how to identify, correct, and evaluate sources of error
in an experiment and how to express the accuracy and precision of
measurements when collecting data or reporting results.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Example 1:
Suppose the number 1492 is correct to the four decimal places
given.
In other words, it is an approximation to a true value that lies
somewhere in the interval between 14915 and 14925.
The error is then at most five units in the fifth place, or half a unit
in the fourth. In such a case the approximation is said to have four
significant digits.
Similarly, 14.92 has two correct decimal places and four
significant digits provided its error does not exceed 005.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Example 2:
When 1.492 is multiplied by 1.066, the product is 1.590472.
Computers work to a fixed "word length," all numbers being
tailored to that length.
Assuming a fictitious (not real) four-digit machine, the above
product would be rounded to 1.590. Such roundoff errors are
algorithm errors and are made by the unavoidable millions in
modern computing.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Errors
Three general types of errors occur in lab measurements:
1. Random errors.
2. Systematic errors.
3. Gross errors.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Random Errors
Random (or indeterminate) errors are caused by uncontrollable
fluctuations in variables that affect experimental results. For
example, air fluctuations occurring as students open and close lab
doors cause changes in pressure readings. A sufficient number of
measurements result in evenly distributed data scattered around an
average value or mean.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
This positive and negative scattering of data is characteristic of
random errors. The estimated standard deviation (the error range for
a data set) is often reported with measurements because random
errors are difficult to eliminate. Also, a "best-fit line" is drawn
through graphed data in order to "smooth out" random error.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Systematic errors
Systematic (or determinate) errors are instrumental, methodological,
or personal mistakes causing "lopsided" (Unbalanced) data, which is
consistently deviated in one direction from the true value.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Systematic errors
Examples of systematic errors: an instrumental error results when a
spectrometer drifts away from calibrated settings; a methodological
error is created by using the wrong indicator for an acid-base
titration; and, a personal error occurs when an experimenter records
only even numbers for the last digit of buret volumes. Systematic
errors can be identified and eliminated after careful inspection of the
experimental methods, cross-calibration of instruments, and
examination of techniques.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Gross Error
Gross errors are caused by experimenter carelessness or equipment
failure. These "outliers" are so far above or below the true value that
they are usually discarded when assessing data.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Precision of a Set of Measurements
A data set of repetitive measurements is often expressed
as a single representative number called the mean or
average. The mean ( 𝒙 ഥ ) is the sum of individual
measurements (xi) divided by the number of
measurements (N).
(Mean)
σ𝑖=1
𝑛 𝑥𝑖
𝑥ҧ = … (1)
𝑁
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Precision (reproducibility) is quantified by calculating the
average deviation (for data sets with 4 or fewer repetitive
measurements) or the standard deviation (for data sets
with 5 or more measurements). Precision is the opposite of
uncertainty Widely scattered data results in a large
average or standard deviation indicating poor precision.
Note: Both calculations contain the deviation from the
mean ( 𝑥𝑖 – 𝑥ҧ ), the difference between the individual
experimental value and the mean value.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Error Definitions
True Value = Approximation + Error
Et = True value – Approximation (+/-)
True error
true error
True fractional relative error
true value
true error
True percent relative error, t 100%
true value
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
• For numerical methods, the true value will be
known only when we deal with functions that can
be solved analytically (simple systems). In real
world applications, we usually not know the answer
a priori. Then
Approximate error
a 100%
Approximation
• Iterative approach, example Newton’s method
Current approximation - Previous approximation
a 100%
Current approximation
(+ / -)
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
• Many numerical methods are interative, that is they
involve repeating the same calculation many times. In
terms of error analysis, two types of error emerge, local
and global errors. The local error is the error introduced
during one operation of the iterative process. The global
error is the accumulative error over many iterations.
• Note that the global error is not simply the sum of the
local errors due to the nonlinear nature of many problems
although often it is assumed to be so because of the
difficulties in measuring the global error.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Sources of Errors in Numerical Calculations
• There are at least two sources of errors in numerical calculations:
1. Rounding Errors
2. Truncation (chopping) Errors
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
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, they cannot
precisely represent certain exact base-10 numbers.
• Fractional quantities are typically represented in
computer using “floating point” form, e.g.,
Integer part
exponent
[Link]
mantissa Base of the number system
used
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Figure 3
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Figure 4
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chopping
Example:
p=3.14159265358 to be stored on a base-10 system
carrying 7 significant digits.
p=3.141592 chopping error t=0.00000065
If rounded
p=3.141593 t=0.00000035
• Some machines use chopping, because rounding adds
to the computational overhead. Since number of
significant figures is large enough, resulting chopping
error is negligible.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.