0% found this document useful (0 votes)
76 views22 pages

Module 1 - Introduction To Numerical Techniques

Uploaded by

Brian Samende
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views22 pages

Module 1 - Introduction To Numerical Techniques

Uploaded by

Brian Samende
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

NUMERICAL METHODS

MA 311
MODULE 1: INTRODUCTION
TO NUMERICAL TECHNIQUES
Musango Lungu, D Eng

School of Mines and Mineral Sciences


Chemical engineering department
2023 @ copyright M.L.
INTRODUCTION TO NUMERICAL
TECHNIQUES
• Numerical methods are techniques by which mathematical problems are
formulated so that they can be solved with arithmetic operations.
• Although there are many kinds of numerical methods, they have one
common characteristic of large numbers of tedious arithmetic calculations.
• With the development of fast, efficient digital computers, the role of numerical
methods in engineering problem solving has increased dramatically .
REASONS FOR STUDYING NUMERICAL METHODS
(i) Capability of handling large systems of equations, non-linear and
complicated geometries that are not uncommon in engineering practice and
that are often impossible to solve analytically.
(ii) Helps in understanding underlying theories of commercial and open source
computational packages.
(iii) Development of user defined sub-routines and programs.
(iv) Numerical methods are an efficient vehicle for learning to use computers.
INTRODUCTION TO NUMERICAL
TECHNIQUES
• Numerical methods provide a vehicle for you to reinforce your
understanding of mathematics.
APPROXIMATIONS AND ROUND OFF ERRORS
• Numerical methods have errors associated with them because they only
give approximate solutions and not exact answers.
• For many applied engineering problems, we cannot obtain analytical
solutions.
• Therefore, we cannot compute exactly the errors associated with our
numerical methods.
• In these cases, we must settle for approximations or estimates of the
errors.
• Identification, quantification, and minimization of these errors is thus
important.
INTRODUCTION TO NUMERICAL
TECHNIQUES
• There are two main forms of numerical errors i.e. round off errors and
truncation errors.
• Round-off error is due to the fact that computers can represent only
quantities with a finite number of digits.
• Truncation error is the discrepancy introduced by the fact that numerical
methods may employ approximations to represent exact mathematical
operations and quantities.
ACCURACY AND PRECISION
• The errors associated with both calculations and measurements can be
characterized with regard to their accuracy and precision.
• Accuracy refers to how closely a computed or measured value agrees
with the true value.
• Precision refers to how closely individual computed or measured
values agree with each other.
INTRODUCTION TO NUMERICAL
TECHNIQUES
• To illustrate concepts of accuracy and precision, consider the Figure
below:

(a) Inaccurate and imprecise

(b) accurate and imprecise

(c) inaccurate and precise

(d) accurate and precise


INTRODUCTION TO NUMERICAL
TECHNIQUES
ERROR DEFINITIONS
• As aforementioned there are two types of errors i.e. round off and
truncation errors.
• For both types, the relationship between the exact, or true, result and
the approximation can be formulated as:
True value = approximation + error (1)
• Rearranging equation 1 , the numerical error is equal to the
discrepancy between the true value and the approximation :
Et = true value − approximation (2)
where Et is used to designate the exact value of the error.
• A shortcoming of this definition is that it takes no account of the order of
magnitude of the value under examination.
INTRODUCTION TO NUMERICAL
TECHNIQUES
• One way to account for the magnitudes of the quantities being evaluated
is to normalize the error to the true value:
true value -approximation
et
true value (3)
• where εt designates the true percent relative error.
• This can be expressed as a percentage by multiplying by 100.
• Alternatively the absolute relative error is calculated which gives the sense
of magnitude only:
true value -approximation
e t 
true value (4)
INTRODUCTION TO NUMERICAL
TECHNIQUES
Example 1
Suppose your vehicle covers a distance of 100 m but the odometer reads
99 m. The following day, a distance of 10 m is covered and this time the
odometer records 9m. Compute (a) the true error and (b) the true
percent relative error for each case.
Solution
Case 1: Case 2:
Et= 100 - 99 = 1m Et = 10 - 9 = 1m
100  99 10  9
et  0.01 et  0.1
100 10
Although the true error is the same for both cases, the relative error for
case 1 is larger.
INTRODUCTION TO NUMERICAL
TECHNIQUES
• For equations 3 and 4 we used a subscript t to signify that the error is
normalized to the true value.
• 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 will obviously not know the true answer a
priori.
• For these situations, an alternative is to normalize the error using the best
available estimate of the true value, that is, to the approximation itself:
(5)
approximate error
ea 100%
approximation
where subscript a signifies error is normalized to an approximate value.
INTRODUCTION TO NUMERICAL
TECHNIQUES
• For certain numerical methods use an iterative approach to compute
answers.
• In such an approach, a present approximation is made on the basis of
a previous approximation.
• This process is performed repeatedly, or iteratively, to successively
compute (we hope) better and better approximations.
• For such cases, the error is often estimated as the difference between
previous and current approximations:
current approximation - previous approximation
ea 100%
current approximation (6)
INTRODUCTION TO NUMERICAL
TECHNIQUES
Example 2
In mathematics, functions can often be represented by infinite
series. For example, the exponential function can be computed using
2 3 n
x x x
e x  1  x    ... 
2 3! n!
Thus, as more terms are added in sequence, the approximation becomes a
better and better estimate of the true value of ex .
(i) Starting with the simplest version, ex = 1, add terms one at a time to
estimate e0.5 .
(ii) After each new term is added, compute the true and approximate
percent relative errors.
Note that the true value is e0.5 = 1.648721 . . . .
INTRODUCTION TO NUMERICAL
TECHNIQUES
(iii) Add terms until the absolute value of the approximate error
estimate εa falls below a pre-specified error criterion εs conforming to
three significant figures.
Solution
First step is to determine the error criterion that ensures a result is correct
to at least three significant figures:
e s   0.5  102 n  %
e s   0.5  1023  %  0.05%

Next add the terms and estimate error


ex = 1 + x
or for x = 0.5, e0.5 = 1 + 0.5 = 1.5
INTRODUCTION TO NUMERICAL
TECHNIQUES
1.648721  1.5 1.5  1
et 100%  9.02% ea 100%  33.3%
1.648721 1.5

• Because εa is not less than the required value of εs , we would continue the
computation by adding another term, x2 ∕2!, and repeating the error
calculation.
• The process is continued until εa < εs .
• Thus, after six terms are included, the approximate error falls below
εs = 0.05% and the computation is terminated.
• Thus, after six terms are included, the approximate error falls below
εs = 0.05% and the computation is terminated.
INTRODUCTION TO NUMERICAL
TECHNIQUES
Truncation Errors and the Taylor Series
• Truncation errors are those that result from using an approximation
in place of an exact mathematical procedure.
• Taylor series provides a means to predict a function value at one point
in terms of the function value and its derivatives at another point.
• In particular, the theorem states that any smooth function can be
approximated as a polynomial.
• The first term in the series is:
f  xi 1   f  xi  (7)
• This relationship is called the zero-order approximation and indicates
that the value of f at the new point is the same as its value at the old
point.
INTRODUCTION TO NUMERICAL
TECHNIQUES
• The first-order approximation is developed by adding another term to
yield:
f  xi 1   f  xi   f   xi  xi 1  xi  (8)

• The additional first-order term consists of a slope f ′(xi ) multiplied by the


difference between xi+1 and xi .
• A second-order term is added to the series to capture some of the
curvature that the function might exhibit:
f   xi 
f  xi 1   f  xi   f   xi  xi 1  xi    xi 1  xi 
2

2! (9)
INTRODUCTION TO NUMERICAL
TECHNIQUES
• In a similar manner, additional terms can be included to develop
the complete Taylor. f   xi 
f  xi 1   f  xi   f   xi  xi 1  x    i 1 
2
x  x
2!
f   xi  f n  xi 
(10)
xi 1  x   ...   xi 1  x   R n
3 n

3! n!
• A remainder term is included to account for all terms from n+1 to infinity:
n 1
f x  x  x n1
Rn   i 1 i 
 n (11)
1!

• where the subscript n connotes that this is the remainder for the nth-
order approximation
x x x xi 1
• is a value of that lies somewhere between and .
INTRODUCTION TO NUMERICAL
TECHNIQUES
• It is often convenient to simplify the Taylor series by defining a step size
h  xi 1  xi :
f   xi  2 f   xi  3 f n  xi  n (12)
f  xi 1   f  xi   f   xi  h  h  h  ...  h  Rn
2! 3! n!

• where the remainder term is now


f n 1 x  n 1
Rn  h
 n  1! (13)
Example 3
Use zero- through fourth-order Taylor series expansions to approximate
the function:
f  x   0.1x 4  0.15 x 3  0.5 x 2  0.25 x  1.2
INTRODUCTION TO NUMERICAL
TECHNIQUES
• from xi = 0 with h = 1. That is, predict the function’s value at xi+1 = 1.
Solution
• This is known function thus we can compute f(x) between 0 and 1.
• f(0) = 1.2 and f(1) = 0.2
• Thus, the true value that we are trying to predict is 0.2.
• Taylor series approximation for n=0 is f  xi 1   1.2
• Thuse t  0.2  1.2  1.0 at x = 1.
INTRODUCTION TO NUMERICAL
TECHNIQUES
For n=1, the first derivative must be determined and evaluated at x=0:
• f ′(0) = −0.4(0.0) 3 − 0.45(0.0) 2 − 1.0(0.0) − 0.25 = −0.25
• Therefore, the first-order approximation is f  xi 1   1.2  0.25h and for
h=1, f  xi 1   0.95.
• e t  0.2  0.95  0.75
For n=2, the second derivative is evaluated at x=0:
• f ″(0) = −1.2(0.0) 2 − 0.9(0.0) − 1.0 = −1.0
• Therefore f  xi 1   1.2  0.25h  0.5h 2 and for h=1, f  xi 1   0.45 .
• e t  0.2  0.45  0.25
• Inclusion of the third and the fourth derivatives results in exactly the
same equation we started with:
f  x   1.2  0.25h  0.5h 2  0.15h3  0.1h 4
INTRODUCTION TO NUMERICAL
TECHNIQUES
• where the remainder term is R  f x  h  0
5
5
4
5!
• This is because the fifth derivative of a fourth-order polynomial is zero.
• Taylor series expansion to the fourth derivative yields an exact estimate at
xi+1 = 1:
f 1  1.2  0.25 1  0.5 1  0.15 1  0.1 1
2 3 4

• In general, the nth-order Taylor series expansion will be exact for an


nth-order polynomial.
• For other differentiable and continuous functions, such as exponentials
and sinusoids, a finite number of terms will not yield an exact estimate.
INTRODUCTION TO NUMERICAL
TECHNIQUES
• The remainder term is usually expressed as :
Rn  O  h n 1 

where the nomenclature O  h n1  means that the truncation error is of the
order of h n 1 .
Problems
(1) The following infinite series can be used to approximate e x :
2 3 n
x x x
e x  1  x    ... 
2 3! n!
(i) Prove that this Maclaurin series expansion is a special case of the Taylor
series expansion with xi =0 and h = x .
INTRODUCTION TO NUMERICAL
TECHNIQUES f x e
(ii) Use the Taylor series to estimate   x
at xi+1 = 1 and for xi=0.2.
Employ the zero-, first-, second-, and third-order versions and compute the
absolute relative error for each case.

(2) Develop a Matlab pseudo code for solving Example 2.

END OF MODULE 1

You might also like