Page - 210 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
Image of the Page - 210 -
Text of the Page - 210 -
210 8 SolvingOrdinaryDifferentialEquations
Case2 With acontinuously increasingrate,we couldhavebeenasked tosolve
V ′(t)=V(t), V(0)=1L, 0s<t≤3s.
ThisparticularODE is verysimilar to the ODE we will addresswhen we next turn
topopulationgrowth(in fact, it maybe seenasaspecial caseof the latter).
The Forward Euler Method: A Brief Encounter If we had proceeded to solve
theseODEsbysomethingcalled theForwardEulermethod (orEuler’smethod),we
could(ifwewanted)havewrittenthesolutioncodesexactlyas theyweredeveloped
above!Thus, we havealreadyused the essentials ofEuler’smethodwithout stating
it.
Inthefollowingsections,theForwardEulermethodwillbethoroughlyexplained
and elaborated on, while we demonstrate how the approach may be used to solve
differentODEsnumerically.
8.2 PopulationGrowth:AFirstOrderODE
Our first real taste of differential equations regards modeling the growth of some
population,suchasacellculture,ananimalpopulation,orahumanpopulation.The
ideasevenextend trivially togrowthofmoneyin abank.
LetN(t) be the number of individuals in the population at time t. How can we
predict the evolutionofN with time? Below we shall derivea differential equation
whosesolution isN(t). Theequationwe will derivereads
N′(t)= rN(t), (8.1)
where r is a number. Note that althoughN obviously is an integer in real life, we
modelN as a real-valued function. We choose to do this, because the solutions of
differential equations are (normally continuous) real-valued functions. An integer-
valued N(t) in the model would lead to a lot of mathematical difficulties. Also,
talking about, e.g., 2.5 individuals is no problem in mathematics, even though we
mustbea bit carefulwhenapplyingthis ina practical setting!
You may know, or find out, that the solution N(t) = Cert, where C is
any number. To make this solution unique, we need to fix C, which is done by
prescribing the value ofN at some time, usually at t = 0. IfN(0) is given asN0,
wegetN(t)=N0ert.
In general, a differential equationmodel consistsof a differential equation, such
as(8.1)andan initialcondition,suchasN(0)=N0.Withaknowninitialcondition,
thedifferentialequationcanbe solvedfor the unknownfunctionand thesolution is
unique.
It is very rare that we can find the solution of a differential equation as easy as
the ODE in this example allows. Normally, one has to apply certain mathematical
methods. Still, these methods can only handle some of the simplest differential
equations. However, with numerical methods and a bit of programming, we can
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