Numerical Method: Dr. Ali A. F. Al-Hamadani
Numerical Method: Dr. Ali A. F. Al-Hamadani
Numerical Method: Dr. Ali A. F. Al-Hamadani
Numerical method
You have to make judicious choices as to what numeric method or algorithm you want to use, how accurate you need
your result to be, with what value (starting value) do you want to begin your computation, and others. This chapter is
designed to provide a good transition from the algebraic type of mathematics to the numeric type of mathematics.
We begin with the general concepts such as floating point, roundoff errors, and general numeric errors and their
propagation. This is followed in Sec. 19.2 by the important topic of solving equations of the type by various numeric
methods, including the famous Newton method.
3 numerics and its ideas, such as estimation of errors, order of convergence, numerical methods expressed
in algorithms, and is also informed about the important numeric methods.
equation such as or a more difficult problem of finding the roots of a higher order polynomial.
That you cannot solve by elementary calculus. Such problems, which are difficult or impossible
to solve algebraically, arise frequently in applications. They call for numeric methods, that is,
systematic methods that are suitable for solving, numerically, the problems on computers or
calculators. Such solutions result in tables of numbers, graphical representation (figures), or
both.
On modern computers, which use binary (base 2) numbers, m is limited to k binary digits (e.g., k=8) and n is
limited (see below), giving representations (for finitely many numbers only!)
2 ഥ . 2𝑛 ,
𝑎ത = ±𝑚 𝑚
ഥ = 0. 𝑑1 𝑑2 … 𝑑𝑘 ,
These numbers 𝑎ത are called k-digit binary machine numbers. Their fractional part m (or 𝑚 ഥ ) is called the
mantissa. This is not identical with “mantissa” as used for logarithms. n is called the exponent of 𝑎.
ത
It is important to realize that there are only finitely many machine numbers and that they become less and less
“dense” with increasing a. For instance, there are as many numbers between 2 and 4 as there are between 1024
and 2048. Why?
The smallest positive machine number 1+eps>1 with is called the machine accuracy. It is important to realize
that there are no numbers in the intervals [1,1+eps],[2,2+2.eps],…,[1024,1024+1024.eps],… . This means that,
if the mathematical answer to a computation would be 1024+1024.eps/2, the computer result will be either
1024 or 1024.eps so it is impossible to achieve greater accuracy.
Tuesday, April 21, 2020
Underflow and Overflow
8
The range of exponents that a typical computer can handle is very large. The IEEE (Institute
of Electrical and Electronic Engineers) floating-point standard for single precision is from 2-
126 to 2128 (1.175*10-23 to 3.403*1038 ) and for double precision it is from 2-1022 to 21024
(2.225*10-308 to 1.798*10308 ).
If, in a computation a number outside that range occurs, this is called underflow when the
number is smaller and overflow when it is larger. In the case of underflow, the result is
usually set to zero and computation continues. Overflow might cause the computer to halt.
An error is caused by chopping (= discarding all digits from some decimal on) or
rounding. This error is called roundoff error, regardless of whether we chop or
round. The rule for rounding off a number to k decimals is as follows. (The rule
for rounding off to k significant digits is the same, with “decimal” replaced by
“significant digit.”).
Solution. (a) For 2 decimals we add 5 * 10-(k+1) = 5 * 10-3 =0.005 to the given
number, that is, 1.2345621+0.005=1.23 954621. then we chop off the digits
‘’954621’’ after the space or equivalently 1.23954621-0.00954621=1.23.
(b) 1.2345621+0.0005=1.235 04621, so that for 3 decimals we get 1.234.
(c) 1.23459621 after chopping give us 1.2345 (4 decimals).
(d) 1.23455121 yield 1.23455 (5 decimals)
(e) 1.23454671 yield 1.234546 (6 decimals).
Can you round the number to 7 decimals? (HW1)
Tuesday, April 21,
2020
11
Rounding errors may ruin a computation completely, even a small computation. In general, these
errors become the more dangerous the more arithmetic operations (perhaps several millions!) we
have to perform. It is therefore important to analyze computational programs for expected
rounding errors and to find an arrangement of the computations such that the effect of rounding
errors is as small as possible.
As mentioned, the arithmetic in a computer is not exact and causes further errors; however,
these will not be relevant to our discussion.
Tuesday, April 21,
2020
12
Loss of Significant Digits
For 𝑥 2 + 40 𝑥 + 2 = 0 we obtain from (4) 𝑥 = −20 ± 398 = −20 ± 19.95, hence x2=-20.00-19.95, involving
no difficulty, and x1=-20.00+19.95 = -0.05, poor value involving loss of digits by subtractive cancellation.
In contrast, (5) gives x1=20.00/(-39.95)=-0.050066, the absolute value of the error being less than one
unit of the last digit, as a computation with more digits shows. The 10S-value is -0.05006265674