Mathematical Modeling the Life Sciences: Numerical Recipes in Python and MATLAB 1st Edition N. G. Cogan instant download
Mathematical Modeling the Life Sciences: Numerical Recipes in Python and MATLAB 1st Edition N. G. Cogan instant download
https://ebookmeta.com/product/mathematical-modeling-the-life-
sciences-numerical-recipes-in-python-and-matlab-1st-edition-n-g-
cogan/
https://ebookmeta.com/product/matlab-for-engineering-and-the-
life-sciences-2nd-edition-joe-tranquillo/
https://ebookmeta.com/product/simulation-with-python-develop-
simulation-and-modeling-in-natural-sciences-engineering-and-
social-sciences-1st-edition-rongpeng-li/
https://ebookmeta.com/product/mathematical-methods-for-life-
sciences-1st-edition-cinzia-bisi/
https://ebookmeta.com/product/incubus-3-1st-edition-brandon-
varnell/
Literary Publishing in America, 1790-1850 William
Charvat
https://ebookmeta.com/product/literary-publishing-in-
america-1790-1850-william-charvat/
https://ebookmeta.com/product/making-revolution-my-life-in-the-
black-panther-party-1st-edition-don-cox/
https://ebookmeta.com/product/pattern-recognition-and-data-
analysis-with-applications-deepak-gupta/
https://ebookmeta.com/product/one-last-breath-1st-edition-k-t-
galloway/
https://ebookmeta.com/product/steel-reinforced-concrete-
structures-assessment-and-repair-of-corrosion-3rd-edition-
mohamed-abdallah-el-reedy/
Comics and Adaptation 1st Edition Benoît Mitaine Editor
David Roche Editor Isabelle Schmitt Pitiot Editor
Aarnoud Rommens David Roche
https://ebookmeta.com/product/comics-and-adaptation-1st-edition-
benoit-mitaine-editor-david-roche-editor-isabelle-schmitt-pitiot-
editor-aarnoud-rommens-david-roche/
Mathematical
Modeling the Life
Sciences
The purpose of this unique textbook is to bridge the gap between the need for numerical
solutions to modeling techniques through computer simulations to develop skill in em-
ploying sensitivity analysis to biological and life sciences applications.
While the text avoids getting mired in the details of numerical analysis, it demonstrates
how to use numerical methods and provides core codes that can be readily altered to fit a
variety of situations.
Numerical scripts in both Python and MATLAB® are included. Python is compiled in
Jupyter Notebook to aid classroom use. Additionally, codes are organized and available
online.
One of the most important skills requiring the use of computer simulations is sensitivity
analysis. Sensitivity analysis is increasingly used in biomathematics. There are numerous
pitfalls to using sensitivity analysis and therefore a need for exposure to worked examples
in order to successfully transfer their use from mathematicians to biologists.
The interconnections between mathematics and the life sciences have an extensive his-
tory. This book offers a new approach to using mathematics to model applications using
computers, to employ numerical methods, and takes students a step further into the realm
of sensitivity analysis. With some guidance and practice, the reader will have a new and
incredibly powerful tool to use.
Differential Equations
Theory, Technique, and Practice, Third Edition
Steven G. Krantz
Abstract Algebra
A First Course, Second Edition
Stephen Lovett
https://www.routledge.com/Textbooks-in-Mathematics/book-series/CANDHTEXBOOMTH
Mathematical
Modeling the Life
Sciences
Numerical Recipes in Python
and MATLAB®
N. G. Cogan
MATLAB® is a trademark of The MathWorks, Inc. and is used with permission. The MathWorks
does not warrant the accuracy of the text or exercises in this book. This book’s use or discussion of
MATLAB® software or related products does not constitute endorsement or sponsorship by The
MathWorks of a particular pedagogical approach or particular use of the MATLAB® software.
Reasonable efforts have been made to publish reliable data and information, but the author and pub-
lisher cannot assume responsibility for the validity of all materials or the consequences of their use.
The authors and publishers have attempted to trace the copyright holders of all material reproduced
in this publication and apologize to copyright holders if permission to publish in this form has not
been obtained. If any copyright material has not been acknowledged please write and let us know so
we may rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced,
transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or
hereafter invented, including photocopying, microfilming, and recording, or in any information stor-
age or retrieval system, without written permission from the publishers.
For permission to photocopy or use material electronically from this work, access www.copyright.
com or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA
01923, 978-750-8400. For works that are not available on CCC please contact mpkbookspermis-
[email protected]
Trademark notice: Product or corporate names may be trademarks or registered trademarks and are
used only for identification and explanation without intent to infringe.
DOI: 10.1201/9781003316930
Publisher’s note: This book has been prepared from camera-ready copy provided by the authors.
I am deeply grateful to my mentors. Clyde Martin invited me into the
field of mathematical biology when I was an unruly undergraduate.
Jim Keener taught me how to look at problems without fear. Lisa
Fauci taught me how to think deeply about a problem, care about the
details, and how to mentor. Yousuff Hussaini taught me to think about
the big picture and look for connections across disciplines and topics.
I have also been blessed with a wonderful group of colleagues and
students at Florida State University and cannot be grateful enough
for this community.
However
Foreword xi
1 Introduction 1
1.1 What Is a Model? . . . . . . . . . . . . . . . . . . . 1
1.2 Projectile Motion . . . . . . . . . . . . . . . . . . . 2
1.3 Problems . . . . . . . . . . . . . . . . . . . . . . . 8
2 Mathematical Background 9
2.1 Mathematical Preliminaries . . . . . . . . . . . . . 9
2.1.1 Linear . . . . . . . . . . . . . . . . . . . . . 11
2.1.2 Nonlinear Equations . . . . . . . . . . . . . 13
2.2 Linearization . . . . . . . . . . . . . . . . . . . . . 15
2.3 Qualitative Analysis . . . . . . . . . . . . . . . . . 18
2.4 Problems . . . . . . . . . . . . . . . . . . . . . . . 20
2.5 Appendix: Planar Example . . . . . . . . . . . . . . 23
vii
viii Contents
4 Ecology 47
4.1 Historical Background . . . . . . . . . . . . . . . . 47
4.2 Single Species Models . . . . . . . . . . . . . . . . 50
4.2.1 The Exponential Model . . . . . . . . . . . . 51
4.2.2 The Logistic Model . . . . . . . . . . . . . . 53
4.2.3 Analysis . . . . . . . . . . . . . . . . . . . . 53
4.2.4 Predator/Prey – Lotka-Volterra . . . . . . . . 54
4.2.5 Analysis . . . . . . . . . . . . . . . . . . . . 56
4.2.6 Sensitivity: One at a Time, Scatterplots . . . 59
4.3 Competitive Exclusion . . . . . . . . . . . . . . . . 62
4.3.1 Model . . . . . . . . . . . . . . . . . . . . . 63
4.3.2 Analysis . . . . . . . . . . . . . . . . . . . . 65
4.3.3 Sensitivity: Linear Regression . . . . . . . . 68
4.4 State of the Art and Caveats . . . . . . . . . . . . . 71
4.5 Problems . . . . . . . . . . . . . . . . . . . . . . . 73
7 Microbiology 135
7.1 Historical Background . . . . . . . . . . . . . . . . 135
7.2 Bacterial Growth: Chemostat . . . . . . . . . . . . . 138
7.2.1 Model . . . . . . . . . . . . . . . . . . . . . 140
7.2.2 Analysis . . . . . . . . . . . . . . . . . . . . 141
7.2.3 Sensitivity Analysis: Correlation Coefficient,
Pearson’s Moment Correlation . . . . . . . . 142
7.3 Multiple State Models: Free/attached . . . . . . . . 146
7.3.1 Model: Freter . . . . . . . . . . . . . . . . . 148
7.3.2 Analysis . . . . . . . . . . . . . . . . . . . . 150
7.3.3 Sensitivity Analysis: Correlation Coefficient,
Spearman . . . . . . . . . . . . . . . . . . . 151
7.4 Cooperators, Cheaters, and Competitions . . . . . . 154
7.4.1 Model . . . . . . . . . . . . . . . . . . . . . 155
7.4.2 Analysis . . . . . . . . . . . . . . . . . . . . 156
7.4.3 Sensitivity Analysis: Sensitivity in Time and
Partial Rank Correlation Coefficient (PRCC) 157
7.5 State of the Art and Caveats . . . . . . . . . . . . . 161
7.6 Problems . . . . . . . . . . . . . . . . . . . . . . . 162
x Contents
9 Neuroscience 189
9.1 Historical Background . . . . . . . . . . . . . . . . 189
9.2 Action Potential . . . . . . . . . . . . . . . . . . . . 192
9.2.1 Model: Hodgkin-Huxley . . . . . . . . . . . 194
9.2.2 Analysis . . . . . . . . . . . . . . . . . . . . 196
9.2.3 Sensitivity Analysis: ANOVA – Sobol’ . . . . 196
9.3 Fitzhugh-Nagumo . . . . . . . . . . . . . . . . . . 201
9.3.1 Model . . . . . . . . . . . . . . . . . . . . . 202
9.3.2 Analysis . . . . . . . . . . . . . . . . . . . . 203
9.3.3 Sensitivity: Moment Independent . . . . . . . 203
9.4 State of the Art and Caveats . . . . . . . . . . . . . 208
9.5 Problems . . . . . . . . . . . . . . . . . . . . . . . 209
10 Genetics 211
10.1 Historical Background . . . . . . . . . . . . . . . . 211
10.2 Heredity . . . . . . . . . . . . . . . . . . . . . . . . 215
10.2.1 Mathematics . . . . . . . . . . . . . . . . . 216
10.2.2 Analysis . . . . . . . . . . . . . . . . . . . . 217
10.2.3 Sensitivity: Factorial Design . . . . . . . . . 218
10.3 State of the Art and Caveats . . . . . . . . . . . . . 219
10.4 Problems . . . . . . . . . . . . . . . . . . . . . . . 220
Bibliography 223
Index 229
Foreword
xi
xii Foreword
what methods can be used. Even fewer people have access to robust
methods that are simple to implement for a variety of problems. Most
packages are either not flexible enough or so packed that it is very
daunting for a non-expert to think about using them. Hopefully with
some guidance and practice, the reader will have a new and incredibly
powerful tool to use.
The book is aimed at undergraduates, but then almost all the books
I used in graduate school claimed the same thing. I have used the
material presented here with both graduates and undergraduates. I
feel that the material is too cursory for a decent graduate course in
mathematics – there are many other mathematical biology textbooks
that are more complete. But, even in a graduate curriculum in mathe-
matics, there is a need for practice in implementation.
Our guess is that the notation is a bit daunting for a typical un-
dergraduate biology major. However with a single course in calculus
and a bit of priming in differential equations, the material is accessible.
In fact, this is one of the aims of the presentation – we believe that a
practicing biologist should have a course in calculus and really needs
some understanding of differential equations. But not what is typically
taught in a mathematics department. Most real biological processes
avoid the issues that are the heart of the mathematics of differential
equations. Dynamical systems (i.e. differential equations where time
is the underlying independent variable) are reasonably well behaved
unless the defining terms are complicated (or more specifically if there
are discontinuities, or certain nonlinearities). But these are typically
not found in biologically motivated problems and are definitely not the
place to start! On the other hand, almost all interesting behaviors in
the real world are nonlinear. A first course in differential equations of-
ten spends the majority of the time on linear equations. So how do we
bridge this gap between the relatively simple and the relatively useful?
Our main tools are numerical. Along with demonstrating sensitivity
analysis, we show many examples of manipulating differential equa-
tions and numerical methods. With this as a foundation, there are many
very practical problems that are within reach.
If a student has no exposure to differential equations, some study
in Chapter 2 will be required. This introduces the main tools that are
needed: Steady-states, stability, qualitative analysis, and time-course
Foreword xiii
plots. One of the most important goals in the book is to allow, en-
courage, and in some sense require that the students can use numerical
methods to calculate much of this. We have provided scripts that are
relatively generic and can produce all of these. Of course, there is no
such thing as a truly black-box script and the user has to be responsi-
ble for understanding that numerical methods can miss steady-states,
produce erroneous estimates and are not able to check the users signs!
The rule of GIGO (Garbage In, Garbage Out) is not just a rule of thumb
but a governing principle. But the methods described and the example
models provides a working template that will be useful to a wide vari-
ety of scientists.
The organization of the book is relatively linear in the topic of sen-
sitivity analysis. The first few chapters deal with one-at-a-time meth-
ods and those that are primarily visual or geometric. For these, we have
included numerical scripts that show the logic and implementation.
The purpose of these files is to show the flow of information and
they are not designed for efficiency. In the later chapters, we introduce
more sophisticated methods (e.g. Screening methods, PRCC, Sobol’).
We have chosen to show how to use other packages for these rather
than show the native code. Partly, the implementation requires infor-
mation that is far beyond the scope of this class to understand – for ex-
ample almost all implementations of Sobol’ indices use Monte Carlo
integration. A second reason for showing this is to show that it is pos-
sible to use very sophisticated methods as long as the student has suf-
ficient background. PRCC, Sobol’, and screening methods are used in
high-level, cutting-edge research – and it is within reach of the stu-
dents.
On the other hand, the biological topics are completely inter-
changeable. We have attempted to use examples that are relevant for
sensitivity methods. For example, it is not useful to use a screening
method for a small number of parameters. But an instructor should be
able to pull biological material from any chapter. The numerical scripts
are reasonably generic and after a few weeks of exposure I have found
students are able to manipulate the codes very easily.
There is some required background, mostly from the mathemat-
ical side. A sequence in calculus and some exposure to differential
equations is really all that is needed. The first three chapters describe
xiv Foreword
N. G. Cogan
Tallahassee, Fl
1
Introduction
include accuracy (how true to the science is the model), flexibility (if
you change the experiment slightly, do you need a brand new model?),
simplicity (is the model tractable?), practicality (does it include things
that are not measurable?).
adjust this for multiple objects? Is this accurate in all velocity regimes?
What about projectile motion in different environments?
In calculus you might have seen this as a question about motion un-
der constant acceleration. Acceleration is the rate of change of velocity,
v(t) and Newton argued that acceleration due to gravity is constant so
that,
dv
= −g.
dt
Since g is a constant, we can integrate both sides,
v(t) = −gt + c0 .
Now we know how the velocity changes over time and velocity is
the rate of change of position,
dy
= −gt + c0 .
dt
Since g and c0 are constant, we can integrate both sides,
1
y(t) = − gt 2 + c0t + c1 . (1.1)
2
You can almost see the correspondence between y = − 21 gt 2 + v0t +
y0 and y(t) = − 12 gt 2 + c0t + c1 , but we have not yet determined the
integration constants. We have to provide some information to do this.
If we denote the initial position – the position at time 0 as y(0) = y0 ,
and plug this into 1.1, we find that c1 = y0 .
So what is c0 ? One way to determine it is if we define the initial
velocity, v(0) = v0 . Then the velocity (the derivative of the position,
y(t)) is,
dy(t)
= −gt + c0 . (1.2)
dt
Evaluating this at t = 0, we find that c0 = v0 .
So the “model” y = − 21 gt 2 + v0t + y0 is really the solution to the
model,
d2y
= −g. (1.3)
dt 2
4 Introduction
Undergraduate Level
1. The classic book by Edelstein-Keshet, Mathematical Models in Bi-
ology [14]. This includes discrete models and continuous ordinary
and partial differential equations models.
2. Modeling aimed primarily at biologist’s by Day and Otto, A Biol-
ogist’s Guide to Mathematical Modeling in Ecology and Evolution
[53]. A welcoming book focusing primarily on ecology an evolu-
tion.
3. A comprehensive book at the calculus level including statistics, ba-
sic programming, introductory models and differential equations:
Mathematics for the Life Sciences by Bodine, Lenhart, and Gross
[6].
4. Essential Mathematical Biology by Britton [9]. This book covers a
lot of ground with a variety of models, methods and examples.
Graduate Level
1. Mathematical Physiology by Keener an Sneyd [36] is full of de-
tailed models of an incredible number of biological topics focused
on human physiology.
2. J.D. Murray’s classic Mathematical Biology. The early, one volume
version is quite good but there are more applications and modern
models in the two volume editions [49, 50].
3. Lee Segal wrote many modeling books and was one of the origi-
nal, modern mathematical biologists see [59] and, although not re-
stricted to biology, the classic modeling with CC Lin is chock full
of methods and examples [42].
8 Introduction
1.3 Problems
Problems 1.1 Show that if an object is accelerating due to gravity,
there is no maximum velocity.
Problems 1.3 Drag force or air resistance is one of the forces that is
neglected in simple projectile motion. One difficulty in modeling air
resistance is that direction of the force depends on the velocity. For a
projectile fired into the air, the drag force acts in the same direction as
gravity when the projectile is moving upward and in the opposite when
the object is moving downward.
(a) Show that the force F = −v2 sgn(v) is consistent with this where
sgn(v) is 1 if v > 0 or −1 if v < 0.
(b) Consider a ball dropped from rest at height, h. Find the solution to
the position as a function of time including air resistance. What is
the terminal velocity? Does the concept make sense?
(c) How fast does an object need to be traveling before air resistance
is 10% of the force of gravity?
2
Mathematical Background
This chapter provides an overview of the main tools for analytic stud-
ies. We briefly review differential equations including linear, constant
coefficient equations, separable equations, linearization, and qualita-
tive analysis.
DOI: 10.1201/9781003316930-2 9
10 Mathematical Background
2.1.1 Linear
Linear initial value problems can be written as,
dny d (n−1) y dy
an (t) n
+ a n−1 (t) + ... + a1 (t) + a0 (t)y(t) = f (t)
dt dt (n−1) dt
y(0) = y0
dy
(0) = y1
dt
..
.
d n−1 y
(0) = yn−1
dt n−1
If the right-hand-side is zero, this is a homogenous equation and
y(t) = 0 is a candidate solution, depending on the initial conditions
provided.
There are many techniques for analyzing these, but we will focus
on one more restrictions. If the coefficients are constant, there is a com-
pletely algorithmic way to understand the solution. For a concrete ex-
ample, we can consider a second order example,
d2y dy
a 2
+ b + cy = 0 (2.1)
dt dt
y(0) = y0
dy
(0) = y1 .
dt
We will come up with a solution by noticing that we already know
a function whose derivatives are related to that function. This is the
definition of the exponential, eλt . So we can guess this as a solution
and substitute this into Equation 2.2. This gives us, aλ 2 eλt + bλ eλt +
ceλt = 0. Since the exponential is never zero, we can simplify this to
find the characteristic equation,
aλ 2 + bλ + c = 0.
This is an algebraic equation for λ , so we know that there are two
values of λ that satisfy the equation,
√
−b ± b2 − 4ac
λ± = .
2a
12 Mathematical Background
where,
0 1
M=
− a − ba
c
Separation of Variables
Consider the differential equation,
dy t
= ,
dt y
y(0) = 1.
2.2 Linearization
Linearization is one of the major concepts in mathematics. Almost all
branches use linearization to approximate the behavior of nonlinear
processes. Applied mathematics relies on linearization to a wide ex-
tent. We will begin with a brief review from calculus since this is often
the first place we see the formal idea of linearization.
Start with a function of an independent variable t, say f (t). Taylors’
theorem states that under some conditions on f , we can write f (t) as
a polynomial, P(t) = ∑i αit i . Moreover, there is an interval about any
point in the domain of f (where f obeys certain restrictions), where
f (t) = P(t). This is a remarkable result that provides insight into how
to integrate and differentiate a range of functions, since we know that
integration and differentiation of polynomials has a predictable pat-
terns. But how do we determine P(t)? Taylors’ theorem states that,
near any point, t, we can write f (t) as,
d2 f
df 2 (a)
f (t) = f (a) + (a)(t − a) + dt (t − a)2 +
dt 2!
dn f
n (a)
... + dt (t − a)n ) + error.
n!
Therefore the coefficients of the polynomials are related to the deriva-
tives of f . It also means that as long as t is close to t, (t − a)i is very
small. So we could approximate f ,
df
f (t) ≈ f (a) + (a)(t − a),
dt
where the error term can usually be estimated using the mean value
theorem. Graphically, this means that near any point, a nice enough
function can be thought of as a line.
16 Mathematical Background
We have used the fact that ȳ does not depend on time to simplify the
left-hand-side and Taylors’ theorem to approximate f (y) with a linear
approximation near ȳ. Notice that this provides an equation for Y (t),
dY (t)
= f 0 (ȳ)Y (t). (2.6)
dt
Since ȳ is constant and this equation is linear, we know exactly how
0
Y (t) behaves since the solution is Y (t) = ke f (ȳ)t . If f 0 (ȳ) > 0, Y (t)
increases and y(t) moves away from ȳ. On the other hand, if f 0 (ȳ) <=,
Y (t) decreases and the solution moves towards ȳ. This says something
specific about the steady-state solution, ȳ. If f 0 (ȳ) > 0, we refer to
the steady-state as unstable. If f 0 (ȳ) < 0, ȳ is stable. If f 0 (ȳ) = 0, the
linearization fails and we have to use different arguments to understand
the behavior.
We can generalize this idea. If we have a system of n nonlinear
differential equations,
dy1
= f1 (y1 , y2 , ..., yn ),
dt
dy2
= f2 (y1 , y2 , ..., yn ),
dt
... ...
dyn
= fn (y1 , y2 , ..., yn )
dt
we define the steady-state as a vector ȳ = (ȳ1 , ȳ2 , ..., ȳn ). We look near
ȳ,
y = ȳ + εY(t),
18 Mathematical Background
Figure 2.1: Phase line showing how f (y) determines whether y increases or
decreases and the qualitative sketch of the solutions, y(t) for different initial
conditions.
We can consider the graph of the function f (y) (see Figure 2.1).
Where f crosses the y-axis, f (y) = 0 which means dy dt is zero there.
That is all roots of f (y) are steady-state solutions. As long as f is
nice enough (continuous and differentiable), if the sign of f changes
between y1 and y2 , there is a root. That means that dy
dt has to be of one
sign between the roots of f . That means that the solution y is either
increasing or decreasing on intervals that do not contain a root. We can
sketch the direction that the solution moves on the “phase-line” (see
Figure 2.1). This can be used to sketch the solution of the equation as
a function of time.
The argument for planar curves is similar but a bit more involved.
Consider the system of equations,
dx
= f (x, y),
dt
dy
= g(x, y).
dt
20 Mathematical Background
Figure 2.2: Phase plane showing the x and y-nullclines. The direction of
increase/decrease in the solution x and y are shown. The same phase plane is
shown with a sketch of the trajectories.
The curves f (x, y) and g(x, y) can be drawn in the (x, y)-plane.
Above f , x must be increasing. While below f , x is decreasing. Simi-
larly, the evolution of y depends on which side of g we are. We can also
see that the solution curve must be tangent to the vector field ( f , g). So
it is possible to see how trajectories move in the phase-plane – where
we think of the solution as a parameterized curve (x(t), y(t)) (see Fig-
ure 2.2).
2.4 Problems
Problems 2.1 Classify the following differential equations as linear
or nonlinear. Also indicate the order of the differential equation
dy
(a) dt + 2y = sin(t)
2
2
(b) t ddt 2y + dy
dt = 1
3
(1+t )
3t
− (1+t 2) y
4
d2y dy
(c) − dt 2 dt =4
Problems 21
5
(d) 4 ddt 5y + cos(t) = 0
3
(e) y ddt 3y − t 2 dy
dt + y = 0
2
(f) t 5 ddt 2y + t 2 dy
dt + y = sin(t)
(b) Suppose that y1 (t) and y2 (t) both solve the equation,
d2y dy
2
+ sin(t) + cos(t)y = 10,
dt dt
dy
(0) = 1,
dt
y(0) = 1.
(c) Show that a linear combination of any two solutions to the differ-
ential equation,
d 2 y dy
+ y2 = 0,
dt 2 dt
dy
(0) = 10,
dt
y(0) = 10.
(b) Find two linear combinations of y1 (t) = eR cos(I) + ieR sin(t) and
y2 (t) = eR cos(I) − ieR sin(t) that involve either cos(t) or sin(t).
22 Mathematical Background
Problems 2.4 The following steps show how to relate the solution to
a second order, linear, constant coefficient differential equation with
complex eigenvalues to real-valued solutions.
2
Consider the differential equation ddt 2y + 4 dy
dt + 5y = 0.
(b) Show that the eigenvalues of the matrix associated with Equation
2.2 are the same as the roots of the characteristic polynomial of
d2y
dt 2
= − ba dy c
dt − a y.
(b)
dy
= y(t + 3),
dt
y(0) = 1,
Appendix: Planar Example 23
Problems 2.7 (a) Sketch the graph of a nonlinear function f (x), along
with the linearization at a point, x0 .
(b) Use the sketch to show how the linearization provides an approxi-
mation of the function value at x0 + δ x.
Problems 2.8 Find and classify the steady-states of the following dif-
ferential equations:
dy
(a) dt = y(1 − y)
dy
(b) dt = −1 + x2
dy
(c) dt = sin(x).
Problems 2.9 Suppose we have the planar system of differential equa-
tions,
dx
= x − xy,
dt
dy
= −y + xy.
dt
(a) Find all equilibiria.
(b) Find the Jacobian at the equilibria.
(c) Classify the equilibria.
x(t) = x̄ + εX(t),
y(t) = ȳ + εY (t).
dx
= f (x, y),
dt
d x̄ + εX(t)
= f (x̄ + εX(t), ȳ + εY (t)),
dt
dX(t) ∂ f (x̄, ȳ) ∂ f (x̄, ȳ)
ε = f (x̄, ȳ) + ε X +ε Y,
dt ∂x ∂y
dX(t) ∂ f (x̄, ȳ) ∂ f (x̄, ȳ)
= X+ Y,
dt ∂x ∂y
for the x-component. Similarly,
d ȳ + εY (t)
= g(x̄ + εX(t), ȳ + εY (t)),
dt
dY (t) ∂ g(x̄, ȳ) ∂ g(x̄, ȳ)
ε = g(x̄, ȳ) + ε X +ε Y,
dt ∂x ∂y
dY (t) ∂ g(x̄, ȳ) ∂ g(x̄, ȳ)
= X+ Y,
dt ∂x ∂y
for the y-component.
The Jacobian matrix is,
" #
∂ f (x̄,ȳ) ∂ g(x̄,ȳ)
J= ∂x ∂x .
∂ g(x̄,ȳ) ∂ g(x̄,ȳ)
∂x ∂y
Where TrJ is the trace of J (the sum of the diagonals) and DetJ is
the determinant of J. Therefore, the eigenvalues of the Jacobian are,
√
TrJ ± TrJ 2 − 4DetJ
λ +± = .
2
The components of the Jacobian completely determine whether the
real part of the eigenvalues is positive, negative or zero.
3
Introduction to the Numerical Methods
3.1 Introduction
The models that we will use in this book are primarily differential
equations. This presents a challenge: How do we understand the mod-
els, use them to make useful predictions or provide insight into the bi-
ology without several additional years of mathematical training? Typ-
ical undergraduate sequences in calculus, linear algebra, differential
equations, and scientific computing are useful for understanding the
nuances of models. Nonlinearities often put models outside the reach
of an undergraduate differential equations class while scientific com-
puting or numerical methods classes often focus on the underlying
methods, rather than the applications.
In this chapter, we discuss the two main computer programs/lan-
guages that we will use throughout the course. The book will inten-
tionally provide parallel numerical scripts in Python and MATLAB® .
Both of these are able to visualize solutions, numerically approximate
solutions to a range of equations, and can be used to automate tasks,
like sampling, which will be important throughout the book. So why
these two packages? Years ago students would have to learn Fortran
to be able to solve equations numerically – adding several semesters
of course work. Both of these languages are widely used and it is our
philosophy that students should have some exposure to all of these lan-
guages and then focus on the one that is most comfortable. There are
many other languages/platforms that are in use. Languages based on
DOI: 10.1201/9781003316930-3 27
28 Introduction to the Numerical Methods
C-like languages including R are widely used. There are open MPI lan-
guages that are able to call both C++ and Fortran libraries such as Julia.
This book is relatively agnostic about the language of choice. MAT-
LAB is well developed and has an excellent support system. Python is
very flexible and has many workgroups that are designed for helping.
They each have some drawbacks as well. MATLAB has a reputation as
a “slow” language because it is interpreted. However, there are many
ways to speed things up with more experience. Python has a specific
culture that can sometimes be overly complicated and difficult to fol-
low since it is so flexible and does not have a centralized structure. R
is a relatively complex language to start with and has a steep learning
curve. All of these platforms will run into mathematical problems that
take an unreasonable amount of time to complete. There should be no
examples in this book where this will happen but keep in mind there is
no perfect language and many, many people studying how to run more
and more complicated problems. The recommendation here is to work
with codes in both MATLAB and Python. Eventually, each person will
find what is most comfortable.
For those that have never done any programming it might seem
strange to use the word “comfortable” – aren’t all language uncomfort-
able? This is definitely true at the beginning. After a bit of work, there
are nuances that make certain languages/programs easier for different
people. For example, MATLAB m-files do not read indentation. So
you can type commands wherever you want. Python is indent-aware
and will throw an error (i.e. break and not run) if the indents do not
match. This means that the typical Python files look neater and more
organized than a typical working m-file. At the same time, MATLAB
is more self-contained and does not need any extra libraries to be read
in so an m-file written for 2018 MATLAB will work on any machine
with 2018 MATLAB. In Python and R, libraries have to be loaded to
“teach” the computers Python what certain commands mean. This can
occasionally cause issues when sharing files.
All of these are accessible and we will start with essentially no
prior knowledge. This chapter is to provide a basic outline of how to
access the platform (MATLAB or Python), how to write a program,
how to edit a program, and how to run a program. We will consider a
few best practices in writing numerical codes in general and in each
platform specifically.
Best Practices in Coding 29
One important note about the codes provided in this book. For
many chapters we have opted for simpler, less efficient, “home-built”
code rather than implementing large scale packages. There are two rea-
sons for this. First, it is much easier to get used to writing and editing
scripts with simpler examples – not to mention developing a better
understanding of the actual methods used. Second, with all packages
there is an issue of upkeep and verification. One cannot assume that
the provided code does not have bugs or errors considering companies
such as Apple, Google, and Microsoft constantly develop patches to
fix codes that cost millions of person hours to develop. Similarly, codes
developed for specific projects are not always updates which means it
is possible to lose functionality permanently if you don’t know how
it was written. Some exceptions here are in the later chapters where
the implementation is beyond what is expected by readers. The book
as chosen a few, well-known, reasonably well-supported implementa-
tions; however these are by no means the only methods available. The
reader should feel free to explore decide what is the cutting-edge im-
plementation.
for many applications, some will only be used for a single model. Your
life will be immeasurably easier if you learn to sort these so you can
find them easily and not accidentally delete or overwrite files you are
working on. The simplest structure that has some redundancy, but is
ordered in a sensible manner might be a folder for the specific course.
Within that folder, you have folders for each chapter. Within each chap-
ter folder you have folders for MATLAB and Python and an assign-
ment folder. Within each of the numerical folders you have folders for
tasks in the assignment (for example Question 1). There is a high like-
lihood of redundancy with this since Question 1 might use the same
script as Question 2. However, there is much less chance that you ac-
cidentally over-write your code answering Question 1 when you start
working on Question 2. Typically, for long-lived projects, there are
specific times when the file structure is revised. But this should be done
as a completely separate task than building the files. It is our expecta-
tion that most students using this book will not need to revise their file
structure.
One disadvantage to this is that when running scripts, there is the
need to change folders. Fortunately in all of our examples, the play
button will query this and automatically change folders for you. But it
is something to be aware of when sharing codes with other people.
44
VI
THE AFFAIRS OF EMPIRE
Although Tushratta’s lust for gold may not have been appreciated in
Thebes, Egypt valued her Mitannian allies who served as a check on
the ambitious Hittites, thereby helping Egypt maintain control over
Syria and Palestine. Not only were princesses from Mitanni welcome
in Egypt, but the Mitannian gods might be of help to the Egyptians.
During the illness of Amenhotep III, Tushratta sent a statue of the
goddess Ishtar from Nineveh to bless the ailing Pharaoh:
Thus saith Ishtar, mistress of all the lands, “To Egypt, to the land
which I love I will go; I will return.” Verily I have now sent her, and
she is gone. Indeed in the time of my father the mistress (Ishtar)
went to that land, and inasmuch as she was revered when she
formerly resided there, so now may my brother tenfold more than
formerly honor her. May my brother honor her and joyfully send
her back, and may she return. May Ishtar, mistress of heaven,
protect my brother and me one hundred thousand years, and may
[29]
our lady give to us both great joy.
Emerging Assyria
47
The Hittite Challenge
The Egyptians, however, did not give serious attention to their Asian
Empire until the reigns of Seti I (1318-1299 B.C.) and Rameses II
(1299-1232 B.C.). During the half century following the fall of Mitanni
the Hittites met no serious opposition in their desire to control the
whole of northern Mesopotamia and the Mediterranean coastal region
of Syria. Not only was a daughter of Suppiluliumas married to the
ruler of the vassal kingdom of Mitanni, but a son, Telepinus, was
installed as ruler of Aleppo in Syria. The Amorites who had been
vassals to Egypt were glad to welcome Hittite aid in establishing their
independence. North Syria, or Amurru, became a hotbed of anti-
Egyptian feeling, and Amorite princes served as unconscious pawns
of Suppiluliumas in weakening Egyptian control in the area and
preparing the way for Hittite domination.
Rib-Addi of Byblos
Abdi-Ashirta and his son Aziru also wrote letters to Egypt affirming
their loyalty. Two of them were addressed by Aziru to Dudu, an
officer of the Egyptian court with a Semitic name. Evidently Dudu
occupied a place in the court of Akhenaton comparable to that which
Joseph occupied some years before (Gen. 41:37-57). Aziru wrote:
There can be no doubt that Rib-Addi, and not Aziru, was truly loyal to
Egypt, for Aziru had made an alliance with Egypt’s enemies, the
Hittites. Writing to the Egyptian Pharaoh, Rib-Addi complained:
I have written to the king, my lord: “They have taken all my cities.
The son of Abdi-Ashirta is their lord. Byblos is the only city 49
that belongs to me.” And have I not sent my messenger to
the king, my lord? But you did not send soldiers, and you did not
permit my messenger to leave.... Send him with auxiliaries. If the
king hates his city, then I will abandon it, and if he permits me, an
old man, to depart, then send your man that he may protect it.
Why was nothing given to me from the palace? I have heard of the
Hati people (i.e. the Hittites) that they burn the lands with fire. I
have repeatedly written but no answer has come to me. All lands
of the king, my lord, are conquered, and my lord holds himself
back from them, and behold, now they bring soldiers from the Hati
[35]
lands to conquer Byblos. Therefore care for thy city.
Rib-Addi stood alone in defending Byblos, but the force of the enemy
proved too much. He fled to Beirut where he found refuge in the
palace of its prince, Ammunira, with whom he was related by
marriage. Byblos fell, but Rib-Addi still hoped for aid from Egypt to
win it back. From Beirut he wrote:
If the king holds back in respect to the city, all the cities of Canaan
(Kinahni) will be lost to him.... But let the king, my lord, quickly
[36]
send archers that they may take the city at once.
Finally Egypt did act. Aziru was apprehended and taken to Egypt
where he was evidently detained for some time. A son of Aziru
addressed a letter to the Egyptian official Dudu begging him for his
father’s release:
Aziru is your servant. Do not detain him there. Send him back
quickly that he may protect the lands of the king, our Lord.
And all lands and all Sudu-people have said, “Aziru does not come
from Egypt.” And now the Sudu steal out of the lands and exalt
themselves against me, saying, “Your father dwells in Egypt, so we
[37]
will make hostility with you.”
50
Lab‘ayu of Shechem
To the king, my lord and my sun, say: Thus says Biridya, the
faithful servant of the king. At the feet of the king, my lord and my
sun, seven and seven times I fall. Let the king know that ever since
the archers returned, Lab‘ayu has carried on hostilities against me,
and we are not able to pluck the wool, and we are not able to go
outside the gate in the presence of Lab‘ayu since he has learned
that you have not given archers, and now his face is set to take
Megiddo, but let the king protect his city lest Lab‘ayu seize it.
Indeed, the city is destroyed by death from pestilence and disease.
Let the king give one hundred garrison troops lest Lab‘ayu seize it.
Verily there is no other purpose in Lab‘ayu. He seeks to destroy
[39]
Megiddo.
Abdi-Khepa of Jerusalem
And the king, my lord, should know that Abdi-Khepa has taken my
city out of my hand. Further, let the king, my lord, ask if I have
taken a man, or even an ox or an ass from him.... Further, Lab‘ayu
who had taken our cities is dead, but verily Abdi-Khepa is another
[44]
Lab‘ayu and he takes our cities.
The king, my lord, should know that the ‘Apiru have arisen in the
land which the god of the king, my lord, has given me, and they
have attacked it, and the king my lord, should know that all my
brothers have abandoned me. I and Abdi-Khepa alone are left to
fight against the ‘Apiru, and Zurata, the prince of Akko, and
Indurata the prince of Achsaph, were the ones who hastened to
[45]
my help.
To the king, my lord and my sun, say: Thus Biridya, the true
servant of the king, my lord and my sun, seven times and seven
times I fall. Let the king be informed concerning his servant and
concerning his city. Behold I am working in the town of Shunama,
and I bring men of the corvée, but behold the governors who are
with me do not as I do; they do not work in the town of Shunama;
and they do not bring men for the corvée, but I alone bring men
for the corvée from the town of Yapu. They come from Shunama
and likewise from the town of Nuribda. So let the king be informed
[46]
concerning his city.
The ‘Apiru
Although the place names of the Amarna texts are parallel to those of
the Old Testament, the personal names are totally different. In
Joshua we read of Adoni-zedek, not Abdi-Khepa, as king of
Jerusalem, and a number of other kings are named for the period of
the conquest (cf. Josh. 10:3). Meredith G. Kline, who holds to the
early date of the Exodus (1440 B.C.) has suggested that the conquest
of Canaan by Joshua precedes the Amarna Age and that the ‘Apiru of
the Amarna letters may actually be the forces of Cushan Rishathaim,
Israel’s first oppressor during the time of the Judges. He concludes
that the ‘Apiru are not to be associated with Israel, but rather must
be regarded as oppressors—the first of a series of such oppressors
[48]
described in the Book of Judges.
55
VII
TRADE AND COMMERCE DURING THE AMARNA
AGE
By the Amarna Age the Mediterranean had become a highway for the
ships of Egypt, Crete, Cyprus, Ugarit, the Phoenician cities, and even
distant Mycenae. Land routes around the Fertile Crescent saw a
steady stream of caravans bearing tribute to kings and items of trade
for commoners. Horses and lapis lazuli were carried westward from
Babylon, and its king Burnaburiash hoped for large quantities of
Egyptian gold. Caravans were subject to attack, and Burnaburiash
made it clear that it was the duty of Akhenaton to punish such
offenders:
Canaan (Kinahhi) is your land, and its kings are your servants. In
your land I have been violently dealt with. Blind them (i.e., the
raiders) and make good the money which they have stolen. Kill the
people who murdered my servants and avenge their blood, for if
you do not kill these people they will return, and my caravans, or
even your messengers they will murder, and messengers between
us will be intercepted, and if that happens, the inhabitants of the
[50]
land will fall away from you.
Minoan Crete
The Phoenicians
Commerce was not without its dangers. Roving bands of pirates from
Lycia in Asia Minor infested the eastern Mediterranean and even
landed on the coast of the Egyptian Delta. Amenhotep III found it
necessary to organize a police force to patrol the Delta coast and
keep the mouths of the Delta closed to all but lawful ships. The police
manned customs houses and collected duty on all merchandise that
was not consigned to the king. The land routes into Egypt were also
policed, and admission was only granted to those with legitimate
business.
58
VIII
THE ART OF AMARNA
Sunken Relief
One change in the Amarna Age art was purely mechanical. Sunken
relief replaces the traditional raised relief in the ornamentation of the
rock tombs. Davies comments on the technique:
The rock in which they are hewn is far from having the uniform
good quality which would invite bas-reliefs of the usual kind. Nor
was Akhenaton willing, it appears, to employ the flat painting on
plastered walls which was so much in vogue, and which the artists
of Akhetaton also employed at times with good effect. The idea of
modelling in plaster was conceived or adopted; and since figures in
plaster-relief would have been liable to easy injury, the outline was
sunk so far below the general surface as to bring the parts in
highest relief just to its level Nor was this the only measure taken
to ensure durability. The whole design was first cut roughly 59
in sunk-relief in the stone itself. Then a fine plaster was
spread over it, covering all the inequalities and yet having the
support of all points of a solid stone core. While the plaster was
still soft, it was moulded with a blunt tool into the form and
features which the artist desired. Finally the whole was painted, all
the outlines being additionally marked out in red, frequently with
such deviations as to leave the copyist in dilemma between the
[55]
painted and the moulded lines.
Realism
Caricature
Not only informality, but actual caricature tended to mark the art of
Akhetaton. The natural deformities of the king were more than
faithfully reproduced—they were exaggerated. The elongated skull,
long thin neck, pointed chin, obtruding stomach, and abnormally
large hips and thighs of the king may have been emphasized by
artists who felt that any characteristic of a son of Aton deserves
special attention.
The way in which people reacted to the king’s wishes may be seen in
a child’s toy depicted at Akhetaton. A tomb painting “shows a model
chariot drawn by monkeys. In the chariot is another monkey urging
along his steeds (his receding forehead is terribly like the king’s), by
him a monkey princess prods the rump of the horse-monkeys which
are jibbing and refusing to budge an inch in spite of a monkey groom
[58]
who is dragging at their bridles for dear life.” Such caricature
would indicate that the “image” of Pharaoh as a son of Aton 61
has been popularly dispelled, and with it much of his power
over his subjects.
The most violent break with the older convention came in the early
years of Akhenaton’s reign. Before the move to Akhetaton, the
Theban hillside was dotted with tombs decorated with the newer art
forms and bearing inscriptions praising the Pharaoh. With the move
to Amarna, the art conventions matured. Artists developed their own
distinctive tastes and at times modified the prevailing tendencies.
Some of the finest specimens of ancient Egyptian art have come from
the workshop of the sculptor Thutmose, discovered by Ludwig
Borchard during the German expedition at Amarna prior to World War
I. In preparing a series of heads of members of the royal family,
Thutmose chose to refine rather than to stress their physical
peculiarities. Thutmose based his work on keen observation,
augmented by casts taken from life when he wanted to record the
characteristic features of his subject. Among his masterpieces are the
famous painted limestone bust of Nofretete—perhaps the best known
piece of Egyptian art; and an unfinished portrait of the queen now in
the Cairo Museum.
62
IX
THE END OF AN ERA
The high hopes of Akhenaton’s early years met an untimely end. The
Asiatic provinces of Egypt fell away to the Hittites or to local
Canaanite princes who had little sympathy with the Empire. Although
there is no evidence of revolt in Egypt itself, Akhenaton’s alienation
from the older priesthood must have resulted in dislocations of the
economy, and difficulties in the smooth running of government.
Smenkhkare
There is some evidence to suggest that Nofretete lost favor with her
husband and moved to a new palace in the northern sector of
Akhetaton. The king gave high honor to his eldest daughter
Meritaton, whose husband, Smenkhkare became his successor on the
throne of Egypt. We have no records indicating events in the earliest
years of Smenkhkare’s reign but in the third year he is known to have
gone to Thebes. The reason for the visit can only be conjectured, but
it may have been a gesture to appease the Amon priesthood which
was still firmly entrenched there.
Our sources fail us again, but neither Akhenaton nor Smenkhkare are
mentioned after ca. 1350 B.C. Whether they died natural deaths, or
perished at the hands of assassins, can only be guessed. We are not
even sure if Smenkhkare was co-regent with his father-in-law or if
Akhenaton had died before he came to the throne. At most
Smenkhkare reigned but four years. If his trip to Thebes was made to
bring about a reconciliation with the Theban priesthood, it seems to
have failed completely.
63
Tutankhaton-Tutankhamon
My husband died, and I have no son. People say that you have
many sons. If you were to send me one of your sons, he might
become my husband. I am loath to take a servant of mine and
[60]
make him my husband.
Why do you say, “They may try to deceive me.” If I had a son
would I write to a foreign country in a manner which is humiliating
to myself and my country. You do not trust me and tell me such a
thing. He who was my husband died and I have no sons. Shall I
perhaps take one of my servants and make him my husband? I
have not written to any other country. I have written only to you.
People say that you have many sons. Give me one of your sons,
[61]
and he is my husband and king in the land of Egypt.
Suppiluliumas was convinced of the good faith of the young widow
and sent a son to Egypt, but the young man never reached Thebes.
Along the way he was murdered by Egyptians who resented the
thought of a foreigner as their ruler. The result was a period of war
between the Hittites and Egypt. Another son of Suppiluliumas made a
record of the affair:
When my father gave them (the Egyptians) one of his sons (to take
over the kingship), they killed him as they led him there. My father
let his anger run away with him; he went to war against Egypt and
[62]
attacked Egypt.
67