CHAPTER ONE
Introduction to Numerical Methods
1
Objectives
1. The objective of this course is to introduce the students to
numerical methods which can be used to solve mathematical
problems arising in engineering and science that cannot be solved
by exact methods.
2. Introducing programming will be essential; we will use high level
software widely used in science and engineering: MATLAB Introduction to Matlab
By: Awash T.
3. We will illustrate and discuss how numerical methods are used in
practice. We will consider examples from Engineering.
2
Why Numerical Methods so widely used in Engineering?
• Engineers use mathematical modeling (equations and data)
to describe and predict the behavior of systems(LTI …).
• Closed-form (analytical) solutions are only possible and
complete for simple problems (geometry, properties, etc.).
• Computers are widely available, powerful, and (relatively)
cheap.
• Powerful software packages are available (special or
general purpose).
3
A few applications of Numerical Methods in
Engineering:
• Structural/mechanical analysis, design, and behavior.
• Communication/power
✓ Networksimulation
✓ Train and trafficnetworks
• Computational Fluid Dynamics(CFD):
✓ Weather prediction
✓ Groundwater & pollutantmovement
4
Why study Numerical Methods?
Numerical Analysis is a Discipline:
• Need to understand concepts and theory
✓ Know what problems can besolved.
✓ Know what problems cannot be solved, or when
problems will be troublesome.
• Need to understand methods and techniques
✓ Know why methods work, or judge when they are
working.
✓ Be able to create or modify tools (software) as needed.
✓ Evaluate errors, convergence, and stability of
arithmetic approximation 5
Error analysis
Basic Concepts in Error Estimation
The main purpose of numerical analysis and scientific computing is to
develop efficient and accurate methods to compute approximations to
quantities that are difficult or impossible to obtain by analyticmeans.
Sources of Error
Numerical results are affected by many types of errors. Some sources of
error are difficult to influence; others can be reduced or even eliminated
by, for example, rewriting formulas or making other changes in the
computationalsequence.
6
Sources of Numerical Error
1. Round off error
2. Truncationerror
3. Measuringerror
4. Computer error
1) Round offError / number of significant figure
• Caused by representing a number approximately
1 .
0.333333
3
2 1.4142...
7
Problems created by round offerror
• 28 Americans were killed on February 25, 1991 by an Iraqi Scud missile in
Dhahran, Saudi Arabia.
• The patriot defense system failed to track and intercept the Scud. Why?
Problem with Patriot missile
• Clock cycle of 1/10 seconds was represented
in 24-bit fixed point register created an error
of 9.5 x 10-8 seconds.
• The battery was on for 100 consecutive
hours, thus causing an inaccuracy of
= 0.342s
s 3600s
= 9.5 10−8 100hr
0.1s 1hr
• The shift calculated in the ranging system of the missile was 687 meters.
• The target was considered to be out of range at a distance greater
than 137meters.
2)Truncation error
• Error caused by truncating or approximating a mathematical
procedure.
Example1 : Taking only a few terms of a Maclaurin series to ex
2 3
e x = 1+ x + x + x + ....................
2! 3!
𝑥2
If only 3 terms are used, Truncation 𝐸𝑟𝑟𝑜𝑟 = 𝑒 𝑥 − (1 + 𝑥 + 2!
)
Example2: Using a finite x to approximate f (x)
f (x) f (x + x) − f (x)
x
9
Using finite rectangles to approximate an integral.
90
y = x2
60
30
0 x
0 1.5 3 4.5 6 7.5 9 10.5 12
3)Measuring Errors
Why measure errors?
1) To determine the accuracy of numerical results.
2) To develop stopping criteria for iterative algorithms.
3.1 True Error
Defined as the difference between the true value in a calculation and the
approximate value found using a numerical method.
True Error = True Value – Approximate Value
Example:
The derivative, f (x)of a function f (x)
approximated by the equation,
f ' (x) f (x + h) − f(x)
h
If f (x) = 7e0.5x and h = 0.3
a) Find the approximate value of f ' (2)
b) True value of f ' (2)
c) True error for part (a)
11
Solution:
a) For x = 2 and h = 0.3
f ' (2) f (2 + 0.3) − f (2)
0.3
f (2.3) − f (2)
=
0.3
7e 0.5(2.3) − 7e 0.5(2)
=
0.3
= 22.107 −19.028 = 10.263
0.3
b) The exact value of f ' (2) using our knowledge of differential
calculus.
f (x) = 7e 0.5x
f ' (x) = 7 0.5 e0.5x
= 3.5e0.5x
12
So the true value of f ' (2) is
f ' (2) = 3.5e0.5(2)
= 9.5140
True error is calculated as
Et = True Value – Approximate Value
= 9.5140 −10.263 = −0.722
Relative True Error
Defined as the ratio between the true error, and the true value.
True Error
Relative True Error ( t ) =
True Value
percentage of relative true error (%t ) =t *100
13
Example: Relative True Error
Following from the previous example for true error,
find the relative true error for f (x) = 7e0.5x at with f '(2)
h = 0.3
From the previous example,
Et = −0.722
Relative True Error is defined as
t = True Error
True Value
− 0.722
= = −0.075888
9.5140
as a percentage,
t = −0.075888 100% = −7.5888%
14
3.2. Approximate Error
• What can be done if true values are not known or are very difficult to obtain?
• Approximate error is defined as the difference between the present
approximation and the previous approximation.
Approximate Error ( E a ) = Present Approximation – PreviousApproximation
Example: Approximate Error
For f (x) = 7e0.5x at x = 2 find the following,
a) f (2)using h = 0.3
b) f (2) using h = 0.15
c) approximate error for the value of f (2)for part (b)
15
Solution:
a) For x = 2 and h = 0.3
f ' (x) f (x + h) − f (x)
h
f (2 + 0.3) − f (2)
f ' (2)
0.3
f (2.3) − f (2)
=
0.3
7e 0.5(2.3) − 7e 0.5(2)
=
0.3
= 22.107 −19.028 = 10.263
0.3
b) For x = 2 and h = 0.15
f ' (2) f (2 + 0.15) − f (2)
0.15
f (2.15) − f (2)
=
0.15
16
7e 0.5(2.15) − 7e 0.5(2)
=
0.15
20.50 −19.028
= = 9.8800
0.15
c) So the approximate error, Ea is
Ea = Present Approximation – PreviousApproximation
= 9.8800 −10.263
= −0.38300
17
Relative Approximate Error
Defined as the ratio between the approximate error and the present
approximation.
Approximate Error
Relative Approximate Error ( a)=
Present Approximation
percentage of relative true error (% a ) =a *100
Example
For f (x) = 7e0.5x at x = 2 , find the relative approximate
error using values from h = 0.3 and h = 0.15
Solution:
From Example 3, the approximate value of f (2)= 10.263
using h = 0.3 and f (2)= 9.8800 using h = 0.15
Ea = Present Approximation – PreviousApproximation
= 9.8800 −10.263
= −0.38300
18
Solution:
Approximate Error
a =
Present Approximation
− 0.38300 = −0.038765
=
9.8800
as a percentage,
a = − 0 . 0 3 8 7 6 5 1 0 0 % = − 3 . 8 7 6 5 %
Absolute relative approximate errors may also need to be
calculated,
a =| −0.038765 | = 0.038765 or 3.8765%
19
How is Absolute Relative Error used as a stopping criterion?
If |a| s where s is a pre-specified tolerance, then
no further iterations are necessary and the process is stopped.
If at least m significant digits are required to be correct in the final
answer, then
|a| 0.5 10 2 −m %
20
Table of Values
For f (x) = 7e 0.5x
at x = 2 with varying step size,h
h f (2) %a %t m
0.3 10.263 N/A 7.87% 0
0.15 9.8800 3.877% 3.85% 1
0.10 9.7558 1.273% 2.54% 1
0.01 9.5378 2.285% 0.25% 1
0.001 9.5164 0.2249% 0.03% 2
21