Page - 212 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
Image of the Page - 212 -
Text of the Page - 212 -
212 8 SolvingOrdinaryDifferentialEquations
wherek is somearbitrary integer.A computerprogramcaneasily computeN((k+
1)Δt) foruswith theaidofa little loop.
The initial condition
Observe that the computational formula cannot be started unless we have an
initial condition!
The solution ofN′ = rN isN =Cert for any constantC, and the initial
condition is needed to fixC so the solution becomes unique. However, from
a mathematical point of view, knowing N(t) at any point t is sufficient as
initial condition.Numerically,we more literally need an initial condition:we
need to know a starting value at the left end of the interval in order to get the
computationalformulagoing.
In fact, we do not really need a computer in this particular case, since we see
a repetitive pattern when doing hand calculations. This leads us to a mathematical
formulaforN((k+1)Δt):
N((k+1)Δt)=N(kΔt)+ΔtrN(kΔt)=N(kΔt)(1+Δtr)
=N((k−1)Δt)(1+Δtr)2
...
=N0(1+Δtr)k+1 .
Rather than using (8.2) as a computational model directly, there is a strong
traditionforderivinga differentialequationfromthisdifferenceequation.The idea
is to consider a very small time interval Δt and look at the instantaneous growth
as this time interval is shrunk to an infinitesimally small size. In mathematical
terms, it means that we let Δt → 0. As (8.2) stands, letting Δt → 0 will
just produce an equation 0 = 0, so we have to divide by Δt and then take the
limit:
lim
Δt→0 N(t+Δt)−N(t)
Δt = rN(t).
The term on the left-hand side is actually the definition of the derivativeN′(t), so
wehave
N′(t)= rN(t),
which is the correspondingdifferentialequation.
There is nothing in our derivation that forces the parameter r to be constant—it
canchangewith timedueto,e.g.,seasonalchangesormorepermanentenvironmen-
tal changes.
Programming for Computations – Python
A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
- Title
- Programming for Computations – Python
- Subtitle
- A Gentle Introduction to Numerical Simulations with Python 3.6
- Volume
- Second Edition
- Authors
- Svein Linge
- Hans Petter Langtangen
- Publisher
- Springer Open
- Date
- 2020
- Language
- English
- License
- CC BY 4.0
- ISBN
- 978-3-319-32428-9
- Size
- 17.8 x 25.4 cm
- Pages
- 356
- Keywords
- Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
- Category
- Informatik