CVE325 Computational
Methods
Introduction to Numerical Methods
Dr. Jamal A. Abdalla
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
MODELING, COMPUTERS, AND
ERROR ANALYSIS
• Numerical or computational methods are
techniques by which mathematical problems are
formulated so that they can be solved with
arithmetic operations.
• The common characteristics among all numerical
methods that they involve large numbers of
arithmetic calculations.
• The advent of computers increased the role of
numerical methods in solving engineering
problems.
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Non-Computer Methods
In the pre-computer era there were three
methods used for solving engineering
problems:
1. Analytical or Exact Methods – Accurate and
suitable for simple problems, however they are
limited.
2. Graphical Methods – Not very precise, can
solve complex problems. Limited to problems
that can be described in two or three dimensions
3. Use of Calculators and Slide Rules – used to
implement numerical methods manually. They
are slow and tedious
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Numerical Methods and
Engineering Practice
• Numerical methods are powerful problem-solving
tools. They are capable of handling large systems of
equations, nonlinearities and complicated geometries
that are difficult to solve analytically.
• Numerical methods are needed for solving many
engineering problems that you will encounter
during your career.
• Numerical methods reinforce your understanding of
mathematics which is vital for solving engineering
problems.
• Numerical methods is an efficient vehicle for
learning computers and utilizing them in
engineering
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Phases of Engineering Problem
Solving
(a) Pre-computer Era
(b) The computer Era
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Mathematical Background
Roots of Equations:
- Concern with a value that satisfies a single nonlinear
equation.
- It is application is mainly in engineering design
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Mathematical Background
Systems of Linear Algebraic Equations:
- It concerns with values that satisfy system of equations simultaneously.
- Its application is in large systems of interconnected elements such as
structures, electric circuits, fluid networks, curve fitting, differential
equations.
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Mathematical Background
Optimizations:
- Determine a value or values that correspond to the optimal
value of a function.
- It is application is in engineering design context.
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Mathematical Background
Curve Fitting:
They are either regression or interpolation.
- Regression is usually used to fit experimental data. Single curve that
represents the general trend of the data without necessarily passing
through any point.
- Interpolation for determining intermediate points. Used for tabulated
information. The curve passes through all the points
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Mathematical Background
Integration:
- It is the determination of areas under the curve.
- It has many application areas – calculation of centroid of area
of complex shapes, calculation of quantities based on discrete
sets and also in solution of differential equations
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Mathematical Background
Ordinary Differential Equations:
- It is applicable to problems that can be expressed in the rate
of change of a quantity rather than the magnitude of the
quantity.
- Examples are acceleration of falling bodies, etc.
- They are either initial-value problems or boundary-value
problems
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Mathematical Background
Partial Differential Equations:
It is used when the rate of change is a function of
more than one variable
Example is steady-state temperature distribution
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Summary of Topics
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
CVE325 Computational
Methods
Chapter 1
Mathematical Modeling and
Engineering Problem Solving
Dr. Jamal A. Abdalla
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 4th Edition, 2003, McGraw-Hill.
th
Objectives and Outcomes
1. Recognize the difference between analytical and
numerical solutions
2. Understand how conservation laws are employed
to develop mathematical models of physical
systems
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Mathematical Model
A mathematical model can
be defined as a formulation
or equation that expresses
the essential features of a
physical system or process
in mathematical terms
Dependent variable = function of (independent
variables, parameters, forcing functions)
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Mathematical Model and Analytical Solution
Newton Second Law:
Force = Mass X Acceleration
F = ma
Free-body diagram
F = FD – FU
FD = mg
FU = cv
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Acceleration a is given:
a=
The solution of this differential equation is given by:
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Example 1.1
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Numerical Solution of the Analytical Model
Numerical approximation of the mathematical model
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Substitute from the mathematical model
New Value = Old Value + Slope X Step Size
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Example 1.2
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Example 1.2, cont.
Numerical Solution
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Example 1.2, cont.
Numerical Solution Analytical Solution
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Comparison between Analytical and Numerical
Solutions
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Conservation Laws
Change = Increases – decreases
When there is no change, i.e., change = 0,
Increases = Decreases
For the pipe network:
Flow in = Flow out
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Conservation Laws in Engineering Fields
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Practical Issues in Engineering Applications
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
CVE325 Computational Methods
Chapter 2
Programming and Software
Dr. Jamal A. Abdalla
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Objectives and Outcomes
Objectives
• Gain fundamental understanding of programming
and software
Outcomes
1. Understand the basic concept of programming.
2. Understand flowchart and its symbols.
4. Know how to translate structured flowcharts and
pseudocode into code in a high-leveI language.
5. Start to familiarize yourself with MATLAB software
package and its programming capability.
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Computer Programs
A computer program is a set of instructions that
direct the computer to perform certain tasks
Major programming Languages are:
1. C, C++, Java, C-Sharp, C#, Python
2. MATLAB
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Symbols for Flowchart
Flowchart and Pseudocode
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Selection Structures
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Selection Structures
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Selection Structures
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Repetition Structures
Do-Exit or Break Loop
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Repetition Structures
DO-FOR construct
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Example 2.1
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Example 2.1, cont.
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Example 2.1, cont.
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
MATLAB and Pseudocode
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
MATLAB and Pseudocode
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
CVE325 Computational Methods
Chapter 3
and
Chapter 4
Approximations, Round-off and
Truncation Errors
Dr. Jamal A. Abdalla
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Objectives and Outcomes
Objectives
• Gain fundamental understanding of approximations, significant
figures and type of errors in numerical calculations
Outcomes
1. Recognize the distinction between truncation and round-off errors.
2. Understand the concepts of significant figures, accuracy, and
precision.
3. Recognize the difference between true relative error εt, approximate
relative error (εa) and acceptable error (εs), and understand how εa
and εs are used to terminate an iterative computation.
4. Understand how numbers are represented in digital computers and
how this representation induces round-off error. In particular, know the
difference between single and extended precision.
5. Recognize how computer arithmetic can introduce and amplify round-
off errors in calculations. In particular, appreciate the problem of
subtractive cancellation.
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Significant Figures
Significant figures (digits) is the number of digits used to
determine the reliability of a numerical value. The significant
digits are those that can be used with confidence. They usually
correspond to a certain digit plus one.
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Significant Figures and
Round-off Errors
• We say certain results approximation is acceptable if
it agrees with the exact result to certain numbers of
significant digits.
• Some quantities such as pi, e, sqrt(7), etc. cannot be
represented by specific or limited number of digits.
Such numbers can never be represented exactly in
the computer because only finite number has to be
retained.
• Omission of the remaining significant digits is called
round-off error. I.e., round-off error is the result of using
approximate numbers to represent exact numbers.
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Accuracy and Precisions
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
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Accuracy and Precisions
(a)Inaccurate and
imprecise;
(b)accurate and
imprecise;
(c)inaccurate and
precise;
(d)accurate and
precise
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Error Definitions
True values and True Errors
True Error = True value – Approximate Value
True Fractional Relative Error = True Error/True Value
The True Percentage Relative Error is given by:
εt = (True Error/True Value) X 100%
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Error Definitions
Approximate values and Errors
Approximate Error = Current Approximation – previous Approximation
Approximate Fractional Relative Error = Approximate Error/current Approximate
The Approximate Percentage Relative Error is given by:
εa = (Approximate Error/current Approximate) X 100%
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Example 3.1
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Example 3.2
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Example 3.2, cont.
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Example 3.2, cont.
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Round-off Errors
Computer representation of numbers
Fig 3.3
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Computer representation of a Decimal Integer
Fig 3.4
Computer representation of a floating point number
Fig 3.5
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Example 3.3
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Computer representation of a floating point number
Fig 3.6
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Truncation Errors
Truncation errors are those result from
using an approximation in place of an
exact mathematical procedure. For
example approximating the derivative or
slope by a secant as shown below.
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Taylor Series
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Taylor Series
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Example 4.1
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Example 4.1
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Example 4.1
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Example 4.2
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.
Other Types of Error
• Blunders or mistakes
• Formulation errors
• Data uncertainty
Prepared by: Jamal A. Abdalla Ref. Chapra, S. C. and Canale, R. P. , Numerical methods for Engineers , 6th Edition, 2010, McGraw-Hill.