Errors Analysis and Basic Definitions in Numerical Analysis
Errors Analysis and Basic Definitions in Numerical Analysis
in Numerical Analysis
Lecture Notes
Mohammad Sabawi
Department of Mathematics
College of Education for Women
Tikrit University
Email: [email protected]
1
Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1 Introduction 4
1.1 Numerical Analysis: An Introduction . . . . . . . . . . . . . . . . . 4
1.2 Numbers Representation in Computer . . . . . . . . . . . . . . . . 5
1.2.1 Floating-Point Numbers . . . . . . . . . . . . . . . . . . . . 6
1.3 Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.3.1 Error Analysis . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.3.2 Sources of Error in Numerical Computations . . . . . . . . 7
1.3.3 Absolute and Relative Errors . . . . . . . . . . . . . . . . . 8
1.3.4 Roundoff and Truncation Errors . . . . . . . . . . . . . . . 9
1.4 Stable and Unstable Computations: Conditioning . . . . . . . . . . 10
1.5 Convergence and Order of Approximation . . . . . . . . . . . . . . 12
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2
Preface
The aim of these class notes is to cover the necessary materials in a stan-
dard numerical analysis course and it s not intended to add to the plethora
of Numerical Analysis texts. We tried our best to write these notes in con-
cise, clear and accessible way, to make them more attractive to the readers.
These lecture notes cover the basic and fundamental concepts and principles
in numerical analysis and it is not a comprehensive introduction to numer-
ical analysis. We emphasise in these notes on the mathematical principles
via explaining them by the aid of numerical software MATLAB. The pre-
requisite material for this course are a course in Calculus, Linear Algebra
and Differential Equations. A basic knowledge in MATLAB is helpful but
it is not necessary. There is a glut of numerical software nowadays, among
these we chose to use MATLAB because of its wide capabilities in scientific
computing.These notes consist of ten chapters and each chapter ends with a
set of exercises address the topics covered in each chapter.
3
Chapter 1
Introduction
5. Numerical Differentiation.
6. Numerical Integration.
4
7. Numerical Optimisation.
k = m × 10n ,
where m is any real number and the exponent n is an integer. This notation is
called the scientific notation or scientific form and sometimes referred
to as standard form.
1. 0.00000834.
2. 25.45879.
3. 3400000.
5
4. 33.
5. 2, 300, 000, 000.
Solution:
1. 0.00000834 = 8.34 × 10−6 .
2. 25.45879 = 2.545879 × 101 .
3. 3400000 = 3.4 × 106 .
4. 33 = 3.3 × 101 .
5. 2.3 × 109 .
b = ±0.d1 d2 d3 · · · dk × 10n , 1 ≤ d1 ≤ 9, 0 ≤ di ≤ 9,
for each i = 2, · · · , k. These numbers are called k-digit decimal ma-
chine numbers.
6
1.3 Errors
Occurrence of error is unavoidable in the field of scientific computing. In-
stead, numerical analysts try to investigate the possible and best ways to
minimise the error. The study of the error and how to estimate and min-
imise it are the fundamental issues in error analysis.
e = x − x∗ .
7
1.3.3 Absolute and Relative Errors
Definition 3 (Absolute Error). The absolute error ê of the error e is defined
as the absolute value of the error e
ê = |x − x∗ |.
ê |x − x∗ |
ẽ = = , x 6= 0.
|x| |x|
Example 2. Let x = 3.141592653589793 is the value of the constant ratio π
correct to 15 decimal places and x∗ = 3.14159265 be an approximation of x.
Compute the following quantities:
a. The error.
Solution:
a. The error
8
1.3.4 Roundoff and Truncation Errors
Computers represent numbers in finite number of digits and hence some
quantities cannot be represented exactly. The error caused by replacing a
number a by its closest machine number is called the roundoff error and
the process is called correct rounding.
1. x1 = 1.34579.
2. x2 = 1.34679.
3. x3 = 1.34479.
4. x4 = 3.34379.
5. x5 = 2.34579.
Solution:
(i) Rounding:
(a) x1 = 1.35.
(b) x2 = 1.35.
(c) x3 = 1.34.
(d) x4 = 3.34.
(e) x5 = 2.35.
(ii) Chopping:
(a) x1 = 1.34.
(b) x2 = 1.34.
(c) x3 = 1.34.
(d) x4 = 3.34.
(e) x5 = 2.34.
9
1.4 Stable and Unstable Computations: Con-
ditioning
Stability is one of the most important characteristics in any efficient and
robust numerical scheme.
|xf 0 (x)|
Cond(f (x)) = , f (x) 6= 0.
|f (x)|
Note: Condition number of a function f at x in its domain sometimes
denoted by Cf (x).
cond(A) = kAkkA−1 k,
where
kAxk
kAk = max ,
x6=0 kxk
and x is a m × 1 column vector.
10
2. The problem is well-posed or insensitive if cond < 1.
√
Example 4. Find the condition number of the function f (x) = x.
Solution:
√ 1
f (x) = x =⇒ f 0 (x) = √ , x 6= 0,
2 x
implies that
|xf 0 (x)| | 2√x x | 1
cond(f (x)) = = √ = .
|f (x)| | x| 2
This indicates that the small changes in the input date lead to changes in the
output data of half size the changes in the input data.
Example 5. Let
1 −1 1
A = 1 0.5 3 ,
0.1 1 0.3
the inverse of A can be computed by using MATLAB command inv(A) to
obtain
4.7500 −2.1667 5.8333
A−1 = 0.5000 −0.3333 1.6667 .
−3.2500 1.8333 −4.1667
Also, the condition number of A and its inverse can be computed using MAT-
LAB commands cond(A) and cond(inv(A)) to have cond(A) = 37.8704
and cond(A−1 ) = 37.8704. We notice that the matrix A and its inverse have
the same condition number.
Definition 9 (Well-Posed Problem). The problem is well-posed if satisfies
the following three conditions:
a. The solution exists.
b. The solution is unique.
c. The solution depends continuously on problem data.
Otherwise, the problem is called ill-posed.
Definition 10 (Accuracy). It is a measure of closeness of the approximate
solution to the exact solution.
Definition 11 (Precision). It is a measure of closeness of the two or more
measurements to each other.
Remark 2. Note that the accuracy and precision are different and they are
not related. The problem maybe very accurate but imprecise and vice versa.
11
1.5 Convergence and Order of Approxima-
tion
Convergence of the numerical solution to the analytical solution is one of the
important characteristic in any good and reliable numerical scheme.
|an+1 − a| |en+1 |
lim q
= lim = M,
n→∞ |an − a| n→∞ |en |q
Note that the convergence gets more rapid as q gets larger and larger.
1
lim = 0.
n→∞ n
12
Definition 14 (Order of Approximation O(hn )). The function f (h) is said
to be big Oh of the function g(h), if two real constants c, and C exist such
that
|f (h)| ≤ C|g(h)| wheneverh < c,
and denoted by f (h) = O(g(h)). The order of approximation is used to
determine the rate at which a function converges.
13
Exercises
1. 23.123.
3. 0.000001573.
4. 39776444.
5. −345.386443.
6. −23000000.
Exercise 2. Evaluate error, absolute error and relative error of the following
values and their approximations:
2. y = 0.00012887765, y ∗ = 0.00012897766
3. z = 9776.96544, z ∗ = 9775.66544
1. 1.98876.
2. 33.87654.
3. 8.98879.
4. 2.88778.
1. f (x) = cos(x).
14