Download as pdf or txt
Download as pdf or txt
You are on page 1of 33

CHE 358

Numerical Methods
for Engineers

Dr. Martinson Addo Nartey


Dr. K. Mensah-Darkwa

Lesson-01
Mathematical Model & Error Estimation
Learning objectives
❖To introduce students to the concepts of numerical methods
and their applications in solving equations.

❖To create understanding of the various rules governing the


usage of the methods

❖To be able to use numerical methods to solve real world


problems

2
Recommended Textbook
• Chapra S. C. and Canale R. P. (2010), Numerical Methods
for Engineers, 6th Edition, McGraw-Hall.

• Hoffman, J. D. (2001), Numerical Methods for Engineers and


Scientists, 2nd Edition, Marcel Dekker Inc.

• Steven C. Chapra, Raymond P. Canale., (2008), Numerical


Methods for Engineers, 5th edition.

• Daniel Dubin., (2003), Numerical and analytical methods for


scientists and engineers using mathematical, Wiley-
Interscience
Other online tools and resources may be helpful 3
Course Outline
❖Roots
• Bracketing Methods
• Open Methods
❖Linear and non-Linear systems of equations
• Gauss Elimination
• Gauss-Seidel
• LU decomposition/factorization
• Cholesky Factorization
❖Polynomial Interpolation
❖Numerical Integration and Differentiation
❖Ordinary differential equations
• Initial-Value Problems (IVP)
• Boundary-Value Problems (BVP)
➢Applications
4
Assessment

Attendance 10
Quiz 5
Mid-Sem Exam 15
End of Sem Exam 70
Total 100

Grading system
70-100 A;
60-69 B;
50-59 C;
40-49 D;
5
0-39 F
What and why numerical methods?
Numerical methods: techniques by which mathematical problems are
formulated so that they can be solved with arithmetic or logical operation

WHY
• Expands the types of problems that can solved
• Capable of handling large systems of equation, nonlinearities and
complicated geometries.

• Allows for the use of ‘canned’ software with insight


• Efficient vehicle for learning to use computers
• Expressly designed for computer implementation thus ideal use
demonstrates power and limitations of computers.
6
Lesson 1: Mathematical Model
Objectives
• Understand how mathematical models can be formulated on the basis
of scientific principles to simulate the behavior of a simple physical
system

• Understanding how numerical methods afford a means to generate


solutions in a manner that can be implemented on a digital computer.

• Understanding the different types of conservation laws that lie beneath


the models used in the various engineering disciplines

• Appreciate the difference between steady-state and dynamic solutions


of these models

• Learn about the different types of numerical methods 7


A Simple Mathematical Model
• A mathematical model can be broadly defined as a formulation or
equation that expresses the essential features of a physical system
or process in mathematical terms.

• Newton’s second law of motion. Eg. Fall of a coin from high rise building
• Models to predict underground roof collapse at mine site
• Models for the effective separation of molasses from sugar crystals to
speed up production time

• Models can be represented by a functional relationship between


dependent variables, independent variables, parameters, and
forcing functions.
8
Model Function

Dependent independent forcing 


= f , parameters, 
variable  variables functions

▪ Dependent variable - a characteristic that usually reflects the


behavior or state of the system
▪ Independent variables - dimensions, such as time and space,
along which the system’s behavior is being determined
▪ Parameters - constants reflective of the system’s properties or
composition
▪ Forcing functions - external influences acting upon the
system
9
Model Function

The engineering problem-solving


process 10
Model Function Example
• Assuming a bungee jumper is in mid-flight, an analytical model
for the jumper’s velocity, accounting for drag, is

 gcd 
v(t ) =
gm
tanh t 
cd  m 

• Dependent variable - velocity v


• Independent variables - time t
• Parameters - mass m, drag coefficient cd
• Forcing function - gravitational acceleration g
11
Numerical Modeling
• Some system models will be given as implicit functions or as
differential equations - these can be solved either using analytical
methods or numerical methods.

• Example - the bungee jumper velocity equation from before is the


analytical solution to the differential equation

dv cd 2
= g− v
dt m

where the change in velocity is determined by the gravitational


forces acting on the jumper versus the drag force. 12
Model Results
• Using a computer (or a calculator), the model can be used to generate a
graphical representation of the system. For example, the graph below
represents the velocity of a 68.1 kg jumper, assuming a drag coefficient
of 0.25 kg/m
• Exact and analytical solution
gm  gc 
(v=0 at t=0 to t=12s) v(t) = tanh d
t
cd  m 

13
Numerical Methods
• To solve the problem using a numerical method, note that the time
rate of change of velocity can be approximated as:

dv cd 2
= g− v
dt m

dv v v(ti+1) − v(ti )
 =
dt t ti+1 − ti
14
Numerical Results
• Applying Euler's method in 2 s intervals yields:

• How do we improve the solution?


• Smaller steps
15
Bases for Numerical Models
• Conservation laws provide the foundation for many model
functions.

• Different fields of engineering and science apply these laws


to different paradigms within the field.

• Among these laws are:


▪ Conservation of mass
▪ Conservation of momentum
▪ Conservation of charge
▪ Conservation of energy

16
Bases for Numerical Models

17
Bases for Numerical Models

18
Significant figures
• Significant figures are counted from the first non-zero numeral,
starting from left of the number.
• Once the required number of significant figures are counted,
the remaining numerals are deleted based on the following:
• If the first of a group of numbers to be deleted is a 5 or more, the last
significant figure is increased by 1.
• e.g. 9.4534 to two significant figures is 9.5 and 9.45 for three significant
figures.
• If the only number to be dropped is a 5, then the last numeral is rounded to the
next even number
• e.g. 12.235 to four significant figures is 12.24. For 3.465, three significant
figures becomes 3.46
▪ TRY: 0.001354 to two significant figures and 8.1265 to four significant figures.
19
Error Estimation

Objective
• Understanding the distinction between accuracy and precision.

• Learning how to quantify error.

• Learning how error estimates can be used to decide when to


terminate an iterative calculation.

• Understanding roundoff errors and recognize truncation errors


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.

a) Inaccurate and imprecise


b) Accurate and imprecise
c) Inaccurate and precise
d) Accurate and precise
Accuracy and Precision
Inaccuracy (bias): systematic deviation from the truth.

Imprecision (uncertainty): magnitude of scatter.

(a) & (c) are equally biased


(b) & (d) are equally accurate, d is
more precise

Numerical methods should be sufficiently


accurate or unbiased to meet the requirements
of a particular problem. They also should be
precise enough for adequate design.
Error Definitions
• True error (Et): the difference between the true value and the
approximation.
𝐸𝑡 = 𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒 − 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛

• Absolute error (|Et|): the absolute difference between the true


value and the approximation.

• True fractional relative error: the true error divided by the true
value.

• Relative error (𝜀 t): the true fractional relative error expressed as a


percentage.

𝜀𝑡 = 𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒−𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛
𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒
×100%
Error Definitions
• The previous definitions of error relied on knowing a true value.
If that is not the case, approximations can be made to the error.

• The approximate percent relative error can be given as the


approximate error divided by the approximation, expressed as

𝜀𝑎 = 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑒 𝑒𝑟𝑟𝑜𝑟
𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛 ×100%

• For iterative processes, the error can be approximated as the


difference in values between successive iterations.

𝜀𝑎 = 𝑝𝑟𝑒𝑠𝑒𝑛𝑡 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛−𝑝𝑟𝑒𝑣𝑖𝑜𝑢𝑠 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛


𝑝𝑟𝑒𝑠𝑒𝑛𝑡 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛
×100%
Using Error Estimates
• Often, when performing calculations, we may not be concerned
with the sign of the error but are interested in whether the absolute
value of the percent relative error is lower than a prespecified
tolerance 𝜀 s.

• For such cases, the computation is repeated until 𝜀𝑎 < 𝜀𝑠

This relationship is referred to as a stopping criterion.


Using Error Estimates
It can be shown (Scarborough, 1966) that if the following criterion
is met, we can be assured that the result is correct to at least n
significant figures.

 s = ( 0.5 10 2− n
)%
Roundoff Errors
• Roundoff errors arise because digital computers cannot represent
some quantities exactly. There are two major facets of roundoff
errors involved in numerical calculations:

▪Digital computers have size and precision limits on their ability


to represent numbers.
▪Certain numerical manipulations are highly sensitive to
roundoff errors.
Truncation Errors
• Truncation errors are those that result from using an
approximation in place of an exact mathematical procedure.

• Example
Approximation to a derivative using a finite-difference equation:

dv v v(ti +1 ) − v(ti )
 =
dt t ti +1 − ti
Truncation Errors
• Taylor theorem states that any smooth function can be
approximated as a polynomial.
Examples
Given that 𝑓 𝑥 = 9𝑥 2 find 𝑓′(3) at ∆𝑥 = 0.3

Solution:
Approximate value= 56.7
Exact value = 54
Error = 2.7
Relative percentage error = 5%

HINT

𝑓 𝑥 + ∆𝑥 − 𝑓(𝑥)
𝑓 ′ (𝑥) ≅
∆𝑥
Examples
𝑑𝑦
Using Euler’s method, find 𝑦(3) if − 3𝑒 −𝑥 = −0.4𝑦. Take ℎ = 3
𝑑𝑥
and 𝑦(0) = 5
(b) Choose a step size (ℎ) = 1.5
(c) Use a step size of 1 (Homework)
Solution:
(a) (b)
𝑦(3) = 8 𝑦1 = 6.5
𝑇𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒 = 2.763 𝑦2 = 3.604; |𝐸𝑡 | = 30.44%
𝐸𝑡 = −5.237
|ℇ𝑡 | = 190%

HINT
𝑦𝑖+1 = 𝑦𝑖 + 𝑓(𝑥𝑖 , 𝑦𝑖 )(ℎ)
Examples
Starting with e x = 1 estimate e 0.5 by adding terms one at a time.
Compute the true and approximate percent relative errors after each term
addition. Add terms until the absolute value of the approximate error 
a
estimate falls below a prespecified error criterion 𝜀𝑠 conforming to three
significant figures. Use the Maclaurin series expansion
Examples
Use Taylor series expansion with n= 0 to 6 to approximate f(x) = 𝑐𝑜𝑠𝑥 at
𝑥𝑖+1 = 𝜋/3 on the basis of the value of 𝑓 𝑥 and its derivative at 𝑥𝑖 =
𝜋/4

You might also like