Seite - 99 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Bild der Seite - 99 -
Text der Seite - 99 -
4.1 PopulationGrowth 99
lnN lnN0 D tZ
0 r.t/dt
N DN0exp 0
@ tZ
0 r.t/dt 1
A;
which forconstant r results inN DN0ert. Note that exp.t/ is the sameaset.
Aswillbedescribed later,rmust inmorerealisticmodelsdependonN . The
method of separation of variables then requires to integrate RN
N0 N=r.N/dN ,
which quicklybecomesnon-trivial formanychoices of r.N/. The only gener-
ally applicable solutionapproach is thereforeanumericalmethod.
4.1.2 NumericalSolution
There is a huge collection of numerical methods for problems like (4.2), and in
generalanyequationof the formu0 Df.u;t/,whereu.t/ is theunknownfunction
in theproblem,andf is someknownformulaofu andoptionally t. For example,
f.u;t/D ru in(4.2).Wewillfirstpresentasimplefinitedifferencemethod solving
u0 Df.u;t/. The idea is four-fold:
1. IntroduceameshintimewithNtC1points t0;t1;: : :;tNt .Weseektheunknown
u at the mesh points tn, and introduce un as the numerical approximation to
u.tn/, seeFig. 4.1.
2. Assume that thedifferential equation isvalidat themeshpoints.
3. Approximatederivativesbyfinitedifferences, seeFig.4.2.
4. Formulateacomputationalalgorithmthatcancomputeanewvalueunbasedon
previouslycomputedvaluesui, i <n.
An example will illustrate the steps. First, we introduce the mesh, and very
often themesh isuniform, meaning that the spacing between points tn and tnC1 is
constant. Thisproperty implies that
tn Dn t; nD0;1;:: :;Nt :
Second, thedifferential equation is supposed tohold at themeshpoints. Note that
this is an approximation, because the differential equation is originally valid at all
realvaluesof t.Wecanexpress thispropertymathematically as
u0.tn/Df.un;tn/; nD0;1;:: :;Nt :
Forexample,withourmodel equationu0 D ru,wehave the special case
u0.tn/D run; nD0;1;:: :;Nt;
or
u0.tn/D r.tn/un; nD0;1;:: :;Nt;
if r dependsexplicitlyon t.
Programming for Computations – Python
A Gentle Introduction to Numerical Simulations with Python
- Titel
- Programming for Computations – Python
- Untertitel
- A Gentle Introduction to Numerical Simulations with Python
- Autoren
- Svein Linge
- Hans Petter Langtangen
- Verlag
- Springer Open
- Datum
- 2016
- Sprache
- englisch
- Lizenz
- CC BY-NC 4.0
- ISBN
- 978-3-319-32428-9
- Abmessungen
- 17.8 x 25.4 cm
- Seiten
- 248
- Schlagwörter
- Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
- Kategorie
- Informatik