Applied Numerical Methods with MATLAB for Engineers and Scientists 4th Edition Steven C. Chapra Dr. - eBook PDF download
Applied Numerical Methods with MATLAB for Engineers and Scientists 4th Edition Steven C. Chapra Dr. - eBook PDF download
https://ebooksecure.com/download/applied-numerical-methods-with-
matlab-for-engineers-and-scientists-ebook-pdf/
http://ebooksecure.com/product/ebook-pdf-applied-numerical-
methods-with-matlab-for-engineers-and-scientists-4th-edition/
http://ebooksecure.com/product/ebook-pdf-applied-numerical-
methods-4th-edition-by-steven-chapra/
http://ebooksecure.com/product/ebook-pdf-applied-numerical-
methods-3rd-edition-by-steven-chapra/
http://ebooksecure.com/product/numerical-methods-in-engineering-
with-matlab-3rd-edition/
Physics for Scientists and Engineers with Modern
Physics 4th Edition Douglas C. Giancoli - eBook PDF
https://ebooksecure.com/download/physics-for-scientists-and-
engineers-with-modern-physics-ebook-pdf/
https://ebooksecure.com/download/essential-matlab-for-engineers-
and-scientists-ebook-pdf-2/
http://ebooksecure.com/product/ebook-pdf-numerical-methods-in-
engineering-with-matlab-3rd-edition/
https://ebooksecure.com/download/essential-matlab-for-engineers-
and-scientists-ebook-pdf/
http://ebooksecure.com/product/ebook-pdf-numerical-methods-for-
engineers-7th-edition/
Applied Numerical Methods
with MATLAB® for Engineers and Scientists
Fourth Edition
Steven C. Chapra
Berger Chair in Computing and Engineering
Tufts University
APPLIED NUMERICAL METHODS WITH MATLAB® FOR ENGINEERS AND SCIENTISTS,
FOURTH EDITION
Published by McGraw-Hill Education, 2 Penn Plaza, New York, NY 10121. Copyright © 2018 by McGraw-Hill
Education. All rights reserved. Printed in the United States of America. Previous editions © 2012, 2008, and
2005. No part of this publication may be reproduced or distributed in any form or by any means, or stored in a
database or retrieval system, without the prior written consent of McGraw-Hill Education, including, but not
limited to, in any network or other electronic storage or transmission, or broadcast for distance learning.
Some ancillaries, including electronic and print components, may not be available to customers outside the
United States.
1 2 3 4 5 6 7 8 9 LCR 21 20 19 18 17
ISBN 978-0-07-339796-2
MHID 0-07-339796-2
All credits appearing on page or at the end of the book are considered to be an extension of the copyright page.
mheducation.com/highered
To
My brothers,
John and Bob Chapra
and
Steve Chapra teaches in the Civil and Environmental Engineering Department at Tufts
University, where he holds the Louis Berger Chair in Computing and Engineering. His other
books include Numerical Methods for Engineers and Surface Water-Quality Modeling.
Steve received engineering degrees from Manhattan College and the University of
Michigan. Before joining the faculty at Tufts, he worked for the Environmental Protection
Agency and the National Oceanic and Atmospheric Administration, and taught at Texas
A&M University and the University of Colorado. His general research interests focus on
surface water-quality modeling and advanced computer applications in environmental
engineering.
He has received a number of awards for his scholarly contributions, including the
Rudolph Hering Medal, the Meriam/Wiley Distinguished Author Award, and the Chandler-
Misener Award. He has also been recognized as the outstanding teacher at Texas A&M
University (1986 Tenneco Award), the University of Colorado (1992 Hutchinson Award),
and Tufts University (2011 Professor of the Year Award).
Steve was originally drawn to environmental engineering and science because of his
love of the outdoors. He is an avid fly fisherman and hiker. An unapologetic nerd, his love
affair with computing began when he was first introduced to Fortran programming as an
undergraduate in 1966. Today, he feels truly blessed to be able to meld his love of math-
ematics, science, and computing with his passion for the natural environment. In addition,
he gets the bonus of sharing it with others through his teaching and writing!
Beyond his professional interests, he enjoys art, music (especially classical music,
jazz, and bluegrass), and reading history. Despite unfounded rumors to the contrary, he
never has, and never will, voluntarily bungee jump or sky dive.
If you would like to contact Steve, or learn more about him, visit his home page at
http://engineering.tufts.edu/cee/people/chapra/ or e-mail him at steven.chapra@tufts.edu.
iv
CONTENTS
Preface xiv
CHAPTER 1
Mathematical Modeling, Numerical Methods,
and Problem Solving 4
1.1 A Simple Mathematical Model 5
1.2 Conservation Laws in Engineering and Science 12
1.3 Numerical Methods Covered in This Book 13
1.4 Case Study: It’s a Real Drag 17
Problems 20
CHAPTER 2
MATLAB Fundamentals 27
2.1 The MATLAB Environment 28
2.2 Assignment 29
2.3 Mathematical Operations 36
2.4 Use of Built-In Functions 39
2.5 Graphics 42
2.6 Other Resources 46
2.7 Case Study: Exploratory Data Analysis 46
Problems 49
CHAPTER 3
Programming with MATLAB 53
3.1 M-Files 54
3.2 Input-Output 61
v
vi CONTENTS
CHAPTER 4
Roundoff and Truncation Errors 99
4.1 Errors 100
4.2 Roundoff Errors 106
4.3 Truncation Errors 114
4.4 Total Numerical Error 125
4.5 Blunders, Model Errors, and Data Uncertainty 130
Problems 131
CHAPTER 5
Roots: Bracketing Methods 138
5.1 Roots in Engineering and Science 139
5.2 Graphical Methods 140
5.3 Bracketing Methods and Initial Guesses 141
5.4 Bisection 146
5.5 False Position 152
5.6 Case Study: Greenhouse Gases and Rainwater 156
Problems 159
CHAPTER 6
Roots: Open Methods 164
6.1 Simple Fixed-Point Iteration 165
6.2 Newton-Raphson 169
6.3 Secant Methods 174
6.4 Brent’s Method 176
6.5 MATLAB Function: fzero 181
6.6 Polynomials 183
6.7 Case Study: Pipe Friction 186
Problems 191
CONTENTS vii
CHAPTER 7
Optimization 198
7.1 Introduction and Background 199
7.2 One-Dimensional Optimization 202
7.3 Multidimensional Optimization 211
7.4 Case Study: Equilibrium and Minimum Potential Energy 213
Problems 215
CHAPTER 8
Linear Algebraic Equations and Matrices 227
8.1 Matrix Algebra Overview 229
8.2 Solving Linear Algebraic Equations with MATLAB 238
8.3 Case Study: Currents and Voltages in Circuits 240
Problems 244
CHAPTER 9
Gauss Elimination 248
9.1 Solving Small Numbers of Equations 249
9.2 Naive Gauss Elimination 254
9.3 Pivoting 261
9.4 Tridiagonal Systems 264
9.5 Case Study: Model of a Heated Rod 266
Problems 270
CHAPTER 10
LU Factorization 274
10.1 Overview of LU Factorization 275
10.2 Gauss Elimination as LU Factorization 276
10.3 Cholesky Factorization 283
10.4 MATLAB Left Division 286
Problems 287
viii CONTENTS
CHAPTER 11
Matrix Inverse and Condition 288
11.1 The Matrix Inverse 288
11.2 Error Analysis and System Condition 292
11.3 Case Study: Indoor Air Pollution 297
Problems 300
CHAPTER 12
Iterative Methods 305
12.1 Linear Systems: Gauss-Seidel 305
12.2 Nonlinear Systems 312
12.3 Case Study: Chemical Reactions 320
Problems 323
CHAPTER 13
Eigenvalues 326
13.1 Mathematical Background 328
13.2 Physical Background 331
13.3 The Power Method 333
13.4 MATLAB Function: eig 336
13.5 Case Study: Eigenvalues and Earthquakes 337
Problems 340
CHAPTER 14
Linear Regression 346
14.1 Statistics Review 348
14.2 Random Numbers and Simulation 353
14.3 Linear Least-Squares Regression 358
14.4 Linearization of Nonlinear Relationships 366
14.5 Computer Applications 370
14.6 Case Study: Enzyme Kinetics 373
Problems 378
CONTENTS ix
CHAPTER 15
General Linear Least-Squares and Nonlinear Regression 385
15.1 Polynomial Regression 385
15.2 Multiple Linear Regression 389
15.3 General Linear Least Squares 391
15.4 QR Factorization and the Backslash Operator 394
15.5 Nonlinear Regression 395
15.6 Case Study: Fitting Experimental Data 397
Problems 399
CHAPTER 16
Fourier Analysis 404
16.1 Curve Fitting with Sinusoidal Functions 405
16.2 Continuous Fourier Series 411
16.3 Frequency and Time Domains 414
16.4 Fourier Integral and Transform 415
16.5 Discrete Fourier Transform (DFT) 418
16.6 The Power Spectrum 423
16.7 Case Study: Sunspots 425
Problems 426
CHAPTER 17
Polynomial Interpolation 429
17.1 Introduction to Interpolation 430
17.2 Newton Interpolating Polynomial 433
17.3 Lagrange Interpolating Polynomial 441
17.4 Inverse Interpolation 444
17.5 Extrapolation and Oscillations 445
Problems 449
CHAPTER 18
Splines and Piecewise Interpolation 453
18.1 Introduction to Splines 453
18.2 Linear Splines 455
18.3 Quadratic Splines 459
18.4 Cubic Splines 462
18.5 Piecewise Interpolation in MATLAB 468
18.6 Multidimensional Interpolation 473
18.7 Case Study: Heat Transfer 476
Problems 480
x CONTENTS
CHAPTER 19
Numerical Integration Formulas 488
19.1 Introduction and Background 489
19.2 Newton-Cotes Formulas 492
19.3 The Trapezoidal Rule 494
19.4 Simpson’s Rules 501
19.5 Higher-Order Newton-Cotes Formulas 507
19.6 Integration with Unequal Segments 508
19.7 Open Methods 512
19.8 Multiple Integrals 512
19.9 Case Study: Computing Work with Numerical Integration 515
Problems 518
CHAPTER 20
Numerical Integration of Functions 524
20.1 Introduction 524
20.2 Romberg Integration 525
20.3 Gauss Quadrature 530
20.4 Adaptive Quadrature 537
20.5 Case Study: Root-Mean-Square Current 540
Problems 544
CHAPTER 21
Numerical Differentiation 548
21.1 Introduction and Background 549
21.2 High-Accuracy Differentiation Formulas 552
21.3 Richardson Extrapolation 555
21.4 Derivatives of Unequally Spaced Data 557
21.5 Derivatives and Integrals for Data with Errors 558
21.6 Partial Derivatives 559
21.7 Numerical Differentiation with MATLAB 560
21.8 Case Study: Visualizing Fields 565
Problems 567
CONTENTS xi
CHAPTER 22
Initial-Value Problems 579
22.1 Overview 581
22.2 Euler’s Method 581
22.3 Improvements of Euler’s Method 587
22.4 Runge-Kutta Methods 593
22.5 Systems of Equations 598
22.6 Case Study: Predator-Prey Models and Chaos 604
Problems 609
CHAPTER 23
Adaptive Methods and Stiff Systems 615
23.1 Adaptive Runge-Kutta Methods 615
23.2 Multistep Methods 624
23.3 Stiffness 628
23.4 MATLAB Application: Bungee Jumper with Cord 634
23.5 Case Study: Pliny’s Intermittent Fountain 635
Problems 640
CHAPTER 24
Boundary-Value Problems 646
24.1 Introduction and Background 647
24.2 The Shooting Method 651
24.3 Finite-Difference Methods 658
24.4 MATLAB Function: bvp4c 665
Problems 668
McGraw-Hill Connect®
Learn Without Limits
Connect is a teaching and learning platform that is proven
to deliver better results for students and instructors.
Mobile
Connect’s new, intuitive mobile interface gives students
and instructors flexible and convenient, anytime–anywhere
access to all components of the Connect platform.
Adaptive
THE ADAPTIVE
READING EXPERIENCE
DESIGNED TO TRANSFORM
THE WAY STUDENTS READ
SmartBook®
Proven to help students improve grades and study more
efficiently, SmartBook contains the same content within
the print book, but actively tailors that content to the
needs of the individual. SmartBook’s adaptive technology
provides precise, personalized instruction on what the
student should do next, guiding the student to master
and remember key concepts, targeting gaps in knowledge
and offering customized feedback, and driving the student
toward comprehension and retention of the subject matter.
Available on tablets, SmartBook puts learning at the student’s
fingertips—anywhere, anytime.
www.mheducation.com
PREFACE
This book is designed to support a one-semester course in numerical methods. It has been
written for students who want to learn and apply numerical methods in order to solve prob-
lems in engineering and science. As such, the methods are motivated by problems rather
than by mathematics. That said, sufficient theory is provided so that students come away
with insight into the techniques and their shortcomings.
MATLAB® provides a great environment for such a course. Although other en-
vironments (e.g., Excel/VBA, Mathcad) or languages (e.g., Fortran 90, C++) could
have been chosen, MATLAB presently offers a nice combination of handy program-
ming features with powerful built-in numerical capabilities. On the one hand, its
M-file programming environment allows students to implement moderately compli-
cated algorithms in a structured and coherent fashion. On the other hand, its built-in,
numerical capabilities empower students to solve more difficult problems without try-
ing to “reinvent the wheel.”
The basic content, organization, and pedagogy of the third edition are essentially pre-
served in the fourth edition. In particular, the conversational writing style is intentionally
maintained in order to make the book easier to read. This book tries to speak directly to the
reader and is designed in part to be a tool for self-teaching.
That said, this edition differs from the past edition in three major ways: (1) new
material, (2) new and revised homework problems, and (3) an appendix introducing
Simulink.
1. New Content. I have included new and enhanced sections on a number of topics. The
primary additions include material on some MATLAB functions not included in previ-
ous editions (e.g., fsolve, integrate, bvp4c), some new applications of Monte Carlo
for problems such as integration and optimization, and MATLAB’s new way to pass
parameters to function functions.
2. New Homework Problems. Most of the end-of-chapter problems have been modified,
and a variety of new problems have been added. In particular, an effort has been made
to include several new problems for each chapter that are more challenging and dif-
ficult than the problems in the previous edition.
3. I have developed a short primer on Simulink which I have my students read prior to
covering that topic. Although I recognize that some professors may not choose to
cover Simulink, I included it as a teaching aid for those that do.
xiv
PREFACE xv
Aside from the new material and problems, the fourth edition is very similar to the
third. In particular, I have endeavored to maintain most of the features contributing to its
pedagogical effectiveness including extensive use of worked examples and engineering and
scientific applications. As with the previous edition, I have made a concerted effort to make
this book as “student-friendly” as possible. Thus, I’ve tried to keep my explanations straight-
forward and practical.
Although my primary intent is to empower students by providing them with a sound
introduction to numerical problem solving, I have the ancillary objective of making this
introduction exciting and pleasurable. I believe that motivated students who enjoy engi-
neering and science, problem solving, mathematics—and yes—programming, will ulti-
mately make better professionals. If my book fosters enthusiasm and appreciation for these
subjects, I will consider the effort a success.
Finally, I want to thank my family, and in particular my wife, Cynthia, for the love,
patience, and support they have provided through the time I’ve spent on this project.
Steven C. Chapra
Tufts University
Medford, Massachusetts
steven.chapra@tufts.edu
PEDAGOGICAL TOOLS
Theory Presented as It Informs Key Concepts. The text is intended for Numerical
Methods users, not developers. Therefore, theory is not included for “theory’s sake,” for ex-
ample no proofs. Theory is included as it informs key concepts such as the Taylor series, con-
vergence, condition, etc. Hence, the student is shown how the theory connects with practical
issues in problem solving.
Introductory MATLAB Material. The text includes two introductory chapters on how to
use MATLAB. Chapter 2 shows students how to perform computations and create graphs
in MATLAB’s standard command mode. Chapter 3 provides a primer on developing
numerical programs via MATLAB M-file functions. Thus, the text provides students with
the means to develop their own numerical algorithms as well as to tap into MATLAB’s
powerful built-in routines.
Algorithms Presented Using MATLAB M-files. Instead of using pseudocode, this book
presents algorithms as well-structured MATLAB M-files. Aside from being useful com-
puter programs, these provide students with models for their own M-files that they will
develop as homework exercises.
Worked Examples and Case Studies. Extensive worked examples are laid out in detail
so that students can clearly follow the steps in each numerical computation. The case stud-
ies consist of engineering and science applications which are more complex and richer than
the worked examples. They are placed at the ends of selected chapters with the intention
of (1) illustrating the nuances of the methods and (2) showing more realistically how the
methods along with MATLAB are applied for problem solving.
Problem Sets. The text includes a wide variety of problems. Many are drawn from en-
gineering and scientific disciplines. Others are used to illustrate numerical techniques and
theoretical concepts. Problems include those that can be solved with a pocket calculator as
well as others that require computer solution with MATLAB.
1.1 MOTIVATION
What are numerical methods and why should you study them?
Numerical methods are techniques by which mathematical problems are formulated
so that they can be solved with arithmetic and logical operations. Because digital comput-
ers excel at performing such operations, numerical methods are sometimes referred to as
computer mathematics.
In the pre–computer era, the time and drudgery of implementing such calculations
seriously limited their practical use. However, with the advent of fast, inexpensive digital
computers, the role of numerical methods in engineering and scientific problem solving
has exploded. Because they figure so prominently in much of our work, I believe that
numerical methods should be a part of every engineer’s and scientist’s basic education.
Just as we all must have solid foundations in the other areas of mathematics and science,
we should also have a fundamental understanding of numerical methods. In particular, we
should have a solid appreciation of both
their capabilities and their limitations.
Beyond contributing to your overall
education, there are several additional
reasons why you should study numerical
methods:
1. Numerical methods greatly expand the
types of problems you can address.
They are capable of handling large sys-
tems of equations, nonlinearities, and
complicated geometries that are not
uncommon in engineering and science
and that are often impossible to solve
analytically with standard calculus. As
such, they greatly enhance your prob-
lem-solving skills.
2. Numerical methods allow you to use
“canned” software with insight. During
1
2 PART 1 MODELING, COMPUTERS, AND ERROR ANALySIS
your career, you will invariably have occasion to use commercially available prepack-
aged computer programs that involve numerical methods. The intelligent use of these
programs is greatly enhanced by an understanding of the basic theory underlying the
methods. In the absence of such understanding, you will be left to treat such packages
as “black boxes” with little critical insight into their inner workings or the validity of
the results they produce.
3. Many problems cannot be approached using canned programs. If you are conversant
with numerical methods, and are adept at computer programming, you can design
your own programs to solve problems without having to buy or commission expensive
software.
4. Numerical methods are an efficient vehicle for learning to use computers. Because nu-
merical methods are expressly designed for computer implementation, they are ideal for
illustrating the computer’s powers and limitations. When you successfully implement
numerical methods on a computer, and then apply them to solve otherwise intractable
problems, you will be provided with a dramatic demonstration of how computers can
serve your professional development. At the same time, you will also learn to acknowl-
edge and control the errors of approximation that are part and parcel of large-scale
numerical calculations.
5. Numerical methods provide a vehicle for you to reinforce your understanding of math-
ematics. Because one function of numerical methods is to reduce higher mathematics
to basic arithmetic operations, they get at the “nuts and bolts” of some otherwise
obscure topics. Enhanced understanding and insight can result from this alternative
perspective.
With these reasons as motivation, we can now set out to understand how numerical
methods and digital computers work in tandem to generate reliable solutions to mathemati-
cal problems. The remainder of this book is devoted to this task.
This book is divided into six parts. The latter five parts focus on the major areas of nu-
merical methods. Although it might be tempting to jump right into this material, Part One
consists of four chapters dealing with essential background material.
Chapter 1 provides a concrete example of how a numerical method can be employed
to solve a real problem. To do this, we develop a mathematical model of a free-falling
bungee jumper. The model, which is based on Newton’s second law, results in an ordinary
differential equation. After first using calculus to develop a closed-form solution, we then
show how a comparable solution can be generated with a simple numerical method. We
end the chapter with an overview of the major areas of numerical methods that we cover in
Parts Two through Six.
Chapters 2 and 3 provide an introduction to the MATLAB® software environment.
Chapter 2 deals with the standard way of operating MATLAB by entering commands one
at a time in the so-called calculator, or command, mode. This interactive mode provides
a straightforward means to orient you to the environment and illustrates how it is used for
common operations such as performing calculations and creating plots.
1.2 PART ORGANIZATION 3
Chapter 3 shows how MATLAB’s programming mode provides a vehicle for assem-
bling individual commands into algorithms. Thus, our intent is to illustrate how MATLAB
serves as a convenient programming environment to develop your own software.
Chapter 4 deals with the important topic of error analysis, which must be understood
for the effective use of numerical methods. The first part of the chapter focuses on the
roundoff errors that result because digital computers cannot represent some quantities
exactly. The latter part addresses truncation errors that arise from using an approximation
in place of an exact mathematical procedure.
1
Mathematical Modeling,
Numerical Methods,
and Problem Solving
CHAPTER OBJECTIVES
The primary objective of this chapter is to provide you with a concrete idea of what
numerical methods are and how they relate to engineering and scientific problem
solving. Specific objectives and topics covered are
• Learning 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 and appreciating the difference
between steady-state and dynamic solutions of these models.
• Learning about the different types of numerical methods we will cover in this
book.
S
uppose that a bungee-jumping company hires you. You’re given the task of
predicting the velocity of a jumper (Fig. 1.1) as a function of time during the
free-fall part of the jump. This information will be used as part of a larger
analysis to determine the length and required strength of the bungee cord for jumpers
of different mass.
You know from your studies of physics that the acceleration should be equal to the ratio
of the force to the mass (Newton’s second law). Based on this insight and your knowledge
4
1.1 A SIMPLE MATHEMATICAL MODEL 5
Upward force of physics and fluid mechanics, you develop the following mathematical model for the rate
due to air of change of velocity with respect to time,
resistance
___ cd 2
dυ = g − ___
dt mυ
where υ = downward vertical velocity (m/s), t = time (s), g = the acceleration due to
gravity (≅ 9.81 m/s2), cd = a lumped drag coefficient (kg/m), and m = the jumper’s
mass (kg). The drag coefficient is called “lumped” because its magnitude depends on fac-
tors such as the jumper’s area and the fluid density (see Sec. 1.4).
Because this is a differential equation, you know that calculus might be used to obtain
an analytical or exact solution for υ as a function of t. However, in the following pages, we
will illustrate an alternative solution approach. This will involve developing a computer-
oriented numerical or approximate solution.
Aside from showing you how the computer can be used to solve this particular prob-
Downward lem, our more general objective will be to illustrate (a) what numerical methods are and
force due (b) how they figure in engineering and scientific problem solving. In so doing, we will also
to gravity show how mathematical models figure prominently in the way engineers and scientists use
numerical methods in their work.
FIGURE 1.1
Forces acting
on a free-falling
bungee jumper.
Dependent
variable
=f (
independent
variables
, parameters,
forcing
functions ) (1.1)
where the dependent variable is a characteristic that typically reflects the behavior or state
of the system; the independent variables are usually dimensions, such as time and space,
along which the system’s behavior is being determined; the parameters are reflective of
the system’s properties or composition; and the forcing functions are external influences
acting upon it.
The actual mathematical expression of Eq. (1.1) can range from a simple algebraic
relationship to large complicated sets of differential equations. For example, on the basis
of his observations, Newton formulated his second law of motion, which states that the
time rate of change of momentum of a body is equal to the resultant force acting on it. The
mathematical expression, or model, of the second law is the well-known equation
F = ma (1.2)
where F is the net force acting on the body (N, or kg m/s2), m is the mass of the object (kg),
and a is its acceleration (m/s2).
6 MATHEMATICAL MODELING, NUMERICAL METHODS, AND PROBLEM SOLVING
The second law can be recast in the format of Eq. (1.1) by merely dividing both sides
by m to give
a = __
F
m (1.3)
where a is the dependent variable reflecting the system’s behavior, F is the forcing func-
tion, and m is a parameter. Note that for this simple case there is no independent variable
because we are not yet predicting how acceleration varies in time or space.
Equation (1.3) has a number of characteristics that are typical of mathematical models
of the physical world.
• It describes a natural process or system in mathematical terms.
• It represents an idealization and simplification of reality. That is, the model ignores
negligible details of the natural process and focuses on its essential manifestations.
Thus, the second law does not include the effects of relativity that are of minimal
importance when applied to objects and forces that interact on or about the earth’s
surface at velocities and on scales visible to humans.
• Finally, it yields reproducible results and, consequently, can be used for predictive
purposes. For example, if the force on an object and its mass are known, Eq. (1.3) can
be used to compute acceleration.
Because of its simple algebraic form, the solution of Eq. (1.2) was obtained easily.
However, other mathematical models of physical phenomena may be much more complex,
and either cannot be solved exactly or require more sophisticated mathematical techniques
than simple algebra for their solution. To illustrate a more complex model of this kind,
Newton’s second law can be used to determine the terminal velocity of a free-falling body
near the earth’s surface. Our falling body will be a bungee jumper (Fig. 1.1). For this case,
a model can be derived by expressing the acceleration as the time rate of change of the
velocity (dυ/dt) and substituting it into Eq. (1.3) to yield
___
dυ = __
F (1.4)
dt m
where υ is velocity (in meters per second). Thus, the rate of change of the velocity is equal
to the net force acting on the body normalized to its mass. If the net force is positive, the
object will accelerate. If it is negative, the object will decelerate. If the net force is zero, the
object’s velocity will remain at a constant level.
Next, we will express the net force in terms of measurable variables and parameters.
For a body falling within the vicinity of the earth, the net force is composed of two
opposing forces: the downward pull of gravity FD and the upward force of air resistance FU
(Fig. 1.1):
F = FD + FU (1.5)
If force in the downward direction is assigned a positive sign, the second law can be
used to formulate the force due to gravity as
FD = mg (1.6)
2
where g is the acceleration due to gravity (9.81 m/s ).
1.1 A SIMPLE MATHEMATICAL MODEL 7
Air resistance can be formulated in a variety of ways. Knowledge from the science
of fluid mechanics suggests that a good first approximation would be to assume that it is
proportional to the square of the velocity,
FU = −cd υ2 (1.7)
where cd is a proportionality constant called the lumped drag coefficient (kg/m). Thus, the
greater the fall velocity, the greater the upward force due to air resistance. The parameter
cd accounts for properties of the falling object, such as shape or surface roughness, that af-
fect air resistance. For the present case, cd might be a function of the type of clothing or the
orientation used by the jumper during free fall.
The net force is the difference between the downward and upward force. Therefore,
Eqs. (1.4) through (1.7) can be combined to yield
___ cd 2
dυ = g − ___
mυ (1.8)
dt
Equation (1.8) is a model that relates the acceleration of a falling object to the forces
acting on it. It is a differential equation because it is written in terms of the differential rate
of change (dυ/dt) of the variable that we are interested in predicting. However, in contrast
to the solution of Newton’s second law in Eq. (1.3), the exact solution of Eq. (1.8) for the
velocity of the jumper cannot be obtained using simple algebraic manipulation. Rather,
more advanced techniques such as those of calculus must be applied to obtain an exact or
analytical solution. For example, if the jumper is initially at rest (υ = 0 at t = 0), calculus
can be used to solve Eq. (1.8) for
( )
___ ___
___
gm gcd
___
υ(t) = √ cd tanh √ m t (1.9)
where tanh is the hyperbolic tangent that can be either computed directly1 or via the more
elementary exponential function as in
−x
tanh x = _______
x
e −e (1.10)
ex + e−x
Note that Eq. (1.9) is cast in the general form of Eq. (1.1) where υ(t) is the dependent
variable, t is the independent variable, cd and m are parameters, and g is the forcing function.
1
MATLAB allows direct calculation of the hyperbolic tangent via the built-in function tanh(x).
8 MATHEMATICAL MODELING, NUMERICAL METHODS, AND PROBLEM SOLVING
t, s υ, m/s
0 0
2 18.7292
4 33.1118
6 42.0762
8 46.9575
10 49.4214
12 50.6175
∞ 51.6938
According to the model, the jumper accelerates rapidly (Fig. 1.2). A velocity of
49.4214 m/s (about 110 mi/hr) is attained after 10 s. Note also that after a sufficiently
FIGURE 1.2
The analytical solution for the bungee jumper problem as computed in Example 1.1. Velocity
increases with time and asymptotically approaches a terminal velocity.
60
Terminal velocity
40
υ, m/s
20
0
0 4 8 12
t, s
1.1 A SIMPLE MATHEMATICAL MODEL 9
long time, a constant velocity, called the terminal velocity, of 51.6983 m/s (115.6 mi/hr)
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 and acceleration has ceased.
___
dυ ≅ ___ υ(ti+1) − υ(ti )
Δυ = ___________ (1.11)
dt Δt ti+1 − ti
where Δυ and Δt are differences in velocity and time computed over finite intervals,
υ(ti) is velocity at an initial time ti, and υ(ti+1) is velocity at some later time ti+1. Note that
dυ/dt ≅ Δυ/Δt is approximate because Δt is finite. Remember from calculus that
___
dυ = lim ___
Δυ
dt Δt→0 Δt
Equation (1.11) represents the reverse process.
FIGURE 1.3
The use of a finite difference to approximate the first derivative of υ with respect to t.
υ(ti+1)
True slope
dυ/dt
∆υ
Approximate slope
υ(ti ) ∆υ = υ(ti+1) − υ(ti)
∆t ti+1 − ti
ti ti+1 t
∆t
10 MATHEMATICAL MODELING, NUMERICAL METHODS, AND PROBLEM SOLVING
υ(ti+1) − υ(ti )
___________ cd
___ 2
ti+1 − ti = g − m υ(ti )
[ cd
υ(ti+1) = υ(ti ) + g − ___ 2
]
m υ(ti ) (ti+1 − ti ) (1.12)
Notice that the term in brackets is the right-hand side of the differential equation itself
[Eq. (1.8)]. That is, it provides a means to compute the rate of change or slope of υ. Thus,
the equation can be rewritten more concisely as
dυ
υi+1 = υi + ___i Δt (1.13)
dt
where the nomenclature υi designates velocity at time ti, and Δt = ti+1 − ti.
We can now see that the differential equation has been transformed into an equation that
can be used to determine the velocity algebraically at ti+1 using the slope and previous values
of υ and t. If you are given an initial value for velocity at some time ti, you can easily compute
velocity at a later time ti+1. This new value of velocity at ti+1 can in turn be employed to extend
the computation to velocity at ti+2 and so on. Thus at any time along the way,
This approach is formally called Euler’s method. We’ll discuss it in more detail when we
turn to differential equations later in this book.
Solution. At the start of the computation (t0 = 0), the velocity of the jumper is zero.
Using this information and the parameter values from Example 1.1, Eq. (1.12) can be used
to compute velocity at t1 = 2 s:
[
υ = 0 + 9.81 − ____
68.1
2
]
0.25 (0) × 2 = 19.62 m/s
For the next interval (from t = 2 to 4 s), the computation is repeated, with the result
[ ]
0.25 (19.62)2 × 2 = 36.4137 m/s
υ = 19.62 + 9.81 − ____
68.1
1.1 A SIMPLE MATHEMATICAL MODEL 11
60
Terminal velocity
Approximate,
40 numerical solution
υ, m/s
Exact, analytical
solution
20
0
0 4 8 12
t, s
FIGURE 1.4
Comparison of the numerical and analytical solutions for the bungee jumper problem.
t, s υ, m/s
0 0
2 19.6200
4 36.4137
6 46.2983
8 50.1802
10 51.3123
12 51.6008
∞ 51.6938
The results are plotted in Fig. 1.4 along with the exact solution. We can see that the numeri-
cal method captures 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, applying Eq. (1.12) at 1-s intervals results in a smaller
error, as the straight-line segments track closer to the true solution. Using hand calcula-
tions, the effort associated with using smaller and smaller step sizes would make such
numerical solutions impractical. However, with the aid of the computer, large numbers of
calculations can be performed easily. Thus, you can accurately model the velocity of the
jumper without having to solve the differential equation exactly.
12 MATHEMATICAL MODELING, NUMERICAL METHODS, AND PROBLEM SOLVING
As in Example 1.2, a computational price must be paid for a more accurate numeri-
cal result. Each halving of the step size to attain more accuracy leads to a doubling of the
number of computations. Thus, we see that there is a trade-off between accuracy and com-
putational effort. Such trade-offs figure prominently in numerical methods and constitute
an important theme of this book.
√___
gm
υ= c d
Although Eqs. (1.14) and (1.15) might appear trivially simple, they embody the two funda-
mental ways that conservation laws are employed in engineering and science. As such, they
will form an important part of our efforts in subsequent chapters to illustrate the connection
between numerical methods and engineering and science.
1.3 NUMERICAL METHODS COVERED IN THIS BOOK 13
Pipe 2
Flow in = 80
Pipe 1 Pipe 4
Flow in = 100 Flow out = ?
Pipe 3
Flow out = 120
FIGURE 1.5
A flow balance for steady incompressible fluid flow at the junction of pipes.
Table 1.1 summarizes some models and associated conservation laws that figure
prominently in engineering. Many chemical engineering problems involve mass balances
for reactors. The mass balance is derived from the conservation of mass. It specifies that
the change of mass of a chemical in the reactor depends on the amount of mass flowing in
minus the mass flowing out.
Civil and mechanical engineers often focus on models developed from the conserva-
tion of momentum. For civil engineering, force balances are utilized to analyze structures
such as the simple truss in Table 1.1. The same principles are employed for the mechanical
engineering case studies to analyze the transient up-and-down motion or vibrations of an
automobile.
Finally, electrical engineering studies employ both current and energy balances to model
electric circuits. The current balance, which results from the conservation of charge, is simi-
lar in spirit to the flow balance depicted in Fig. 1.5. Just as flow must balance at the junction
of pipes, electric current must balance at the junction of electric wires. The energy balance
specifies that the changes of voltage around any loop of the circuit must add up to zero.
It should be noted that there are many other branches of engineering beyond chemical,
civil, electrical, and mechanical. Many of these are related to the Big Four. For example, chem-
ical engineering skills are used extensively in areas such as environmental, petroleum, and bio-
medical engineering. Similarly, aerospace engineering has much in common with mechanical
engineering. I will endeavor to include examples from these areas in the coming pages.
18 von Kittlitz, Reise nach dem russischen Amerika, &c. ii. 103
sq.
84 Mencius, i. 1. 7. 8.
127 Leviticus, iii. 17; vii. 25 sqq.; xvii. 10 sqq.; xix. 26.
Deuteronomy, xii. 16, 23 sqq.; xv. 23.
The general abstinence from certain kinds of food has thus sprung
from a great variety of causes. Of these I have been able to point
out only some of the more general and obvious. As Sir J. G. Frazer
justly remarks, to explain the ultimate reason why any particular
food is prohibited to a whole tribe or to certain of its members would
commonly require a far more intimate knowledge of the history and
beliefs of the tribe than we possess.129 Even explanations given by
the natives themselves may be misleading, since the original motive
for a custom may have been forgotten, while the custom itself is still
preserved. But I think that, broadly speaking, the general avoidance
of a certain food may be traced to one or several of the following
sources: its disagreeable taste; disgust caused, in the case of animal
food, either by the external appearance of the animal, or by its
unclean habits, or by sympathy, or by associations of some kind or
other, or even by the mere fact that it is commonly abstained from;
the disinclination to kill an animal for food, or, generally, to reduce
the supply of a certain kind of victuals; the idea, whether correct or
false, that the food would injure him who partook of it. From what
has been said in previous chapters it is obvious that any of these
factors, if influencing the manners of a whole community and
especially when supported by the force of habit, may lead not only
to actual abstinence but to prohibitory rules the transgression of
which is apt to call forth moral disapproval. This is particularly the
case at the earlier stages of culture, where a people’s tastes and
habits are most uniform, where the sway of custom is most
powerful, where instinctive aversion most readily develops into moral
indignation, and where man in almost every branch of action thinks
he has to be on his guard against supernatural dangers. And in this,
as in other cases of moral concern, the prohibition may easily be
sanctioned by religion, especially when the abstinence is due to fear
of some mysterious force or quality in the thing avoided. The
religious aspect assumed particular prominence in Hebrewism and
Brahmanism. It is said in the ‘Institutes of Vishnu’ that the eating of
pure food is more essential than all external means of purification;
“he who eats pure food only is truly pure, not he who is only purified
with earth and water.”130 The Koran forbids the eating of “what is
dead, and blood, and flesh of swine, and whatsoever has been
consecrated to other than God.”131 Mediæval Christianity prohibited
the eating of various animals, especially horses, which were not used
as food in the South of Europe, but which the pagan Teutons
sacrificed and ate at their religious feasts.132 The idea that it is
“unchristian” to eat horseflesh has survived even to the present day,
and has, together with the aversion to feeding on a pet animal, been
responsible for the loss of enormous quantities of nourishing food.
Among ourselves the only eatable thing the partaking of which is
generally condemned as immoral is human flesh. But there are a
considerable number of people who think that we ought to abstain
from all animal meat, not only for sanitary reasons, but because man
is held to have no right to subject any living being to suffering and
death for the purpose of gratifying his appetite.
129 Frazer, Golden Bough, i. 391 sq.
130 Institutes of Vishnu, xxii. 89.
139 See Jolly, ‘Recht und Sitte,’ in Bühler, Grundriss der indo-
arischen Philologie, ii. 157.
There still remains a group of restrictions in diet which call for our
consideration, namely, such as refer to the use of intoxicating drinks,
either only prohibiting immoderation or also demanding total
abstinence.
Among a large number of peoples drunkenness is so common that
it can hardly be looked upon as a vice by the community; on the
contrary, it is sometimes an object of pride, or is regarded almost as
a religious duty. An old traveller on the West African Gold Coast says
that the natives teach their children drunkenness at the age of three
or four years, “as if it were a virtue.”156 The Negroes of Accra,
according to Monrad, take a pride in getting drunk, and praise the
happiness of a person who is so intoxicated that he can hardly
walk.157 In ancient Yucatan he who dropped down senseless from
drink in a banquet was allowed to remain where he fell, and was
regarded by his companions with feelings of envy.158 Among the
Pueblo Indians in New Mexico, who are otherwise a sober people,
drunkenness forms a part of their religious festivals.159 So also in the
hill tribes of the Central Provinces of India a large quantity of liquor
is an essential element in their religious rites, and their acts of
worship invariably end in intoxication.160 Of the Ainu in Japan we are
told that “to drink for the god” is their chief act of worship; the more
saké they drink the more devout they are, whereas the gods will be
angry with a person who abstains from the intoxicating drink.161 The
ancient Scandinavians regularly concluded their religious ceremonies
with filling and emptying stoops in honour of their gods; and even
after their conversion to Christianity they were allowed to continue
this practice at the end of their services, with the difference that
they were now required in their toast-drinking to substitute for the
names of their false deities those of the true God and his saints.162
Of the Germans Tacitus states that “to pass an entire day and night
in drinking disgraces no one”;163 and this habit of intoxication the
Anglo-Saxons brought with them to England, where it was nourished
by a damp climate and a marshy soil. In the seventh and eighth
centuries some efforts were made to check drunkenness on the
initiative of Theodore, archbishop of Canterbury, and Egbert,
archbishop of York, and these exertions were supported by the kings
from a political desire to prevent riots and bloodshed.164 The
Penitentials tell us the tale of universal intemperance more
effectively than any description of it could do. A bishop who was so
drunk as to vomit while administering the holy sacrament was
condemned to eighty or ninety days penance, a presbyter to
seventy, a deacon or monk to sixty, a clerk to forty;165 and if a
person was so intoxicated that, pending the rite, he dropped the
sacred elements into the fire or into a river, he was required to chant
a hundred psalms.166 A bishop or priest who persevered in the habit
of drunkenness was to be degraded from his office;167 whilst single
cases of intoxication, if accompanied by vomiting, incurred penance
for a certain number of days—forty for a presbyter or deacon,168
thirty for a monk,169 fifteen for a layman.170 However, these rules
admitted of exceptions: if anybody in joy and glory of our Saviour’s
natal day, or of Easter, or in honour of any saint, vomited through
being drunk, and in so doing had taken no more than he was
ordered by his elders, it mattered nothing; and if a bishop had
commanded him to be drunk he was likewise innocent, unless
indeed the bishop was in the same state himself.171 If these
attempts to encourage soberness produced any change for the
better, it could only have been temporary; for some time afterwards
intemperance was carried to its greatest excess through the practice
and example of the Danes.172 Under the influence of the Normans,
who were a more temperate race, drunkenness, for a time
decreased in England; but after a few reigns the Saxons seem rather
to have corrupted their conquerors than to have been benefited by
their example.173 As late as the eighteenth century drunkenness was
universal among all classes in England. It was then as uncommon for
a party to separate while any member of it remained sober as it is
now for any one in such a party to degrade himself through
intoxication. No loss of character was incurred by habitual excess.
Men in the position of gentlemen congratulated each other upon the
number of bottles emptied; and it would have been considered a
very frivolous objection to a citizen who aspired to the dignity of
Alderman or Mayor that he was an habitual drunkard.174
156 Bosman, Description of the Coast of Guinea, p. 107.
161 Bird, Unbeaten Tracks in Japan, ii. 68, 96. Cf. Batchelor, Ainu
of Japan, p. 31.
177 Ibid. ix. 235, 237; xi. 49, 55; xii. 56.
192 Dorsey, ‘Omaha Sociology,’ in Ann. Rep. Bur. Ethn. iii. 370.