Computational (Numerical) Methods For Chemical Engineers: Chapter One
Computational (Numerical) Methods For Chemical Engineers: Chapter One
CHAPTER ONE
Chemical Engineering, Mathematical Modeling and Computational Methods
Objective
At the end of this chapter, student should be able to
Understand the need for numerical methods, and
Go through the stages (mathematical modeling, solving and implementation) of solving a
particular engineering problem.
Find the true and relative true error,
Find the approximate and relative approximate error,
Relate the absolute relative approximate error to the number of significant digits at least
correct in your answers, and
Know the concept of significant digits.
Know that there are two inherent sources of error in numerical methods – round-off and
truncation error,
Recognize the sources of round-off and truncation error, and
Know the difference between round-off and truncation error.
Understand the basics of Taylor’s theorem,
Write transcendental and trigonometric functions as Taylor’s polynomial
Introduction
1.1. Definition
Mathematical models are an integral part in solving engineering problems. Many times, these
mathematical models are derived from engineering and science principles, while at other times
the models may be obtained from experimental data.
Mathematical models generally result in need of using mathematical procedures that include but
are not limited to:
a. Differentiation,
b. Nonlinear equations,
c. Simultaneous linear equations,
d. Curve fitting by interpolation or regression,
e. Integration, and
f. Differential equations.
These mathematical procedures may be suitable to be solved exactly as you must have
experienced in the series of calculus or applied mathematics courses you have taken, but in most
cases, the procedures need to be solved approximately using numerical methods.
Numerical or Computational methods is a subject concerned with developing methods for
computing, usually approximately, the solution of mathematical expressions which can’t be
solved analytically.
A numerical method is at the heart of the engineering discipline because most engineering
problems whose mathematical models are either very difficult or impossible to solve
Solutions have been derived for some engineering problems using analytical (or exact) methods.
In general there are few closed-form engineering or exact solutions. These solutions are often
useful and provide excellent insight into the behavior of an engineering system.
Advantage: provide excellent insight into the behavior of some systems
Disadvantage: only for simple linear models or simple geometry and low dimensionality
1.2.2 Graphical solutions
Advantage: able to characterize the behavior of systems
Disadvantage: the results are not precise and limited to three or less dimensions
1.2.3 Calculators approaches
Advantage: perfectly adequate for solving complex problems manually
Disadvantage: the calculations are slow, tedious and consistent results are elusive
1.3 Numerical Methods in Engineering Problems Solving
What is a Numerical method?
Numerical methods are techniques by which mathematical problems are formulated so that they
can be solved with arithmetic operations. Numerical methods involve large numbers of tedious
arithmetic calculations. These methods have gained popularity due to the advancements in
efficient computational tools such as digital computers and calculators.
Advantages of numerical methods (NM):
NM are extremely powerful problem-solving tools
Capable of handling large systems of equation, complicated geometries etc., that are
often impossible to solve analytically.
NM are an efficient vehicle for learning to use computers
It is an effective way to learn programming by writing the computer programs.
NM provide a vehicle to reinforce the understanding of mathematics
This is done by reducing higher mathematics to basic arithmetic operations.
With the development of fast, efficient digital computer, the role of numerical methods in
engineering problem solving has increased dramatically in recent years. Although they have
great potential utility, computers are practically useless without a fundamental understanding of
how engineering systems work. This understanding is normally gained from empirical and
theoretical analysis, and is most useful when it is expressed in the form of a mathematical model.
Problem Solving Process
According to the model, the parachutist accelerates rapidly a velocity of 44.87 m/s is attained
after 10s. Note also after a sufficient long time a constant velocity, called terminal velocity is
reached. This velocity is constant because, eventually, the force of gravity will be in balance with
the air resistance. Thus, the net force is zero the acceleration has ceased.
Equation 1 is called an analytical, or exact, solution because it exactly satisfies the original
differential equation. Unfortunately, there are many mathematical models that can’t be solved
exactly. In many of these cases, the only alternative is to develop a numerical solution that
approximates the exact solution.
Case 2: Numerical Method’s
Numerical methods capture the essential features of the exact solution. However, because we
have employed straight-line segments to approximate a continuously curving function, there is
some discrepancy between the two results. One way to minimize such discrepancies is to use a
smaller step size. For example, solving at 1-s interval results in a smaller error, as the straight-
line segment track closer to the true solution.
As mentioned at the beginning of this chapter, we generally see mathematical procedures that
require the solution of nonlinear equations, differentiation, and solution of simultaneous linear
equations, interpolation, regression, integration, and differential equations. A physical example
to illustrate the need for each of these mathematical procedures is given in the beginning of each
chapter. You may want to look at them now to understand better why we need numerical
methods in everyday life.
Numerical techniques yield approximate values and there are always errors associated with the
approximation. Understanding the concept of error is very important to the effective use of
numerical methods. Science for many applied engineering problems we can’t evaluate the true
error associated with our approximation. In this case we must settle for approximation or
estimates of the errors. Since we can’t avoid the error associated with our numerical endeavors,
our next target to answer the question “how much error is present in our calculation? And is it
tolerable?”
Errors
The accuracy of a numerical calculation is quantified by the error of the calculation.
Several types of errors can occur in numerical calculations.
1. Errors in the parameters of the problem (assumed nonexistent).
Example 1
The derivative of a function f (x) at a particular value of x can be approximately calculated by
f ( x h) f ( x )
f ( x) of f (2) For f ( x) 7e 0.5 x and h 0.3 ,
h
Find
a. The approximate value of f (2)
b. The true value of f (2)
c. The true error for part (a)
Q: What is relative true error?
Example 2
The derivative of a function f (x) at a particular value of x can be approximately calculated by
f ( x h) f ( x )
f ' ( x)
h
For f ( x) 7e and h 0.3 , find the relative true error at x 2 .
0.5 x
Example 3
The derivative of a function f (x) at a particular value of x can be approximately calculated by
f ( x h) f ( x )
f ' ( x)
h
For f ( x) 7e and at x 2 , find the following
0.5 x
called the pre-specified tolerance, s . If the absolute relative approximate error a is less than or
equal to the pre-specified tolerance s , that is, |a | s , then the acceptable error has been reached
and no more iterations would be required. Alternatively, one may pre-specify how many
significant digits they would like to be correct in their answer. In that case, if one wants at
least m significant digits to be correct in the answer, then you would need to have the
absolute relative approximate error, |a | 0.5 102m %.
Class activity
If one chooses 6 terms of the Maclaurin series for e x to calculate e 0.7 , how many significant
digits can you trust in the solution? Find your answer without knowing or using the exact
answer.
Error in solving an engineering or science problem can arise due to several factors. First, the
error may be in the modeling technique. A mathematical model may be based on using
assumptions that are not acceptable. For example, one may assume that the drag force on a car is
proportional to the velocity of the car, but actually it is proportional to the square of the velocity
of the car. This itself can create huge errors in determining the performance of the car, no matter
how accurate the numerical methods you may use are. Second, errors may arise from mistakes
in programs themselves or in the measurement of physical quantities. But, in applications of
numerical methods itself, the two errors we need to focus on are
The Patriot defense system consists of an electronic detection device called the range gate. It
calculates the area in the air space where it should look for a Scud. To find out where it should
aim next, it calculates the velocity of the Scud and the last time the radar detected the Scud.
Time is saved in a register that has 24 bits length. Since the internal clock of the system is
measured for every one-tenth of a second, 1/10 is expressed in a 24 bit-register as
0.00011001100110011001100. However, this is not an exact representation. In fact, it would
need infinite numbers of bits to represent 1/10 exactly. So, the error in the representation in
decimal format is
The battery was on for 100 consecutive hours, hence causing an inaccuracy of
s 3600s
9.537108 100 hr
0.1s 1hr
0.3433s
Truncation error is defined as the error caused by truncating a mathematical procedure. For
example, the Maclaurin series for e x is given as
x2 x3
ex 1 x ....................
2! 3!
This series has an infinite number of terms but when using this series to calculate e x , only a finite
number of terms can be used. For example, if one uses three terms to calculate e x , then
x2
e 1 x .
x
2!
The truncation error for such an approximation is
x2
Truncation error = e 1 x ,
x
2!
x3 x4
.......................
3! 4!
But, how can truncation error be controlled in this example? We can use the concept of relative
approximate error to see how many terms need to be considered. Assume that one is calculating
e1.2 using the Maclaurin series, then
1.2 2 1.2 3
e1.2 1 1.2 ...................
2! 3!
Let us assume one wants the absolute relative approximate error to be less than 1 %. In Table 1,
we show the value of e1.2 , approximate error and absolute relative approximate error as a function
of the number of terms, n .
n e 1 .2 Ea a %
1 1 - -
2 2.2 1.2 54.546
3 2.92 0.72 24.658
4 3.208 0.288 8.9776
5 3.2944 0.0864 2.6226
6 3.3151 0.020736 0.62550
Using 6 terms of the series yields a a < 1%.
The use of Taylor series exists in so many aspects of numerical methods that it is imperative to
devote a separate chapter to its review and applications. For example, you must have come
across expressions such as
x2 x4 x6
cos(x) 1 (1)
2! 4! 6!
x3 x5 x7
sin(x) x (2)
3! 5! 7!
x2 x3
ex 1 x (3)
2! 3!
All the above expressions are actually a special case of Taylor series called the Maclaurin series.
Why are these applications of Taylor’s theorem important for numerical methods? Expressions
such as given in Equations (1), (2) and (3) give you a way to find the approximate values of these