Seite - 101 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Bild der Seite - 101 -
Text der Seite - 101 -
4.1 PopulationGrowth 101
Instead of going to the limit t ! 0wecanuse a small t, which yields a com-
putableapproximation tou0.tn/:
u0.tn/ u nC1 un
t :
This isknownasa forwarddifference sincewegoforward in time(unC1) tocollect
informationinu toestimate thederivative. Figure4.2 illustrates the idea. Theerror
of the forwarddifference isproportional to t (oftenwrittenasO. t/, butwewill
notuse thisnotation in thepresentbook).
Wecannowplug in the forwarddifference in ourdifferential equation sampled
at thearbitrarymeshpoint tn:
unC1 un
t Df.un;tn/; (4.3)
orwithf.u;t/D ru inour specialmodelproblemforpopulationgrowth,
unC1 un
t D run: (4.4)
If r dependson time,we insert r.tn/D rn forr in this latter equation.
The fourth step is to derive a computational algorithm. Looking at (4.3), we
realize that ifun shouldbeknown,wecan easily solvewith respect tounC1 to get
a formula foruat thenext time level tnC1:
unC1 DunC tf.un;tn/: (4.5)
Providedwehaveaknownstartingvalue,u0 DU0,wecanuse(4.5) toadvancethe
solutionbyfirst computingu1 fromu0, thenu2 fromu1,u3 fromu2, and so forth.
Suchanalgorithmiscalledanumerical scheme for thedifferential equationand
oftenwrittencompactlyas
unC1 DunC tf.un;tn/; u0 DU0; nD0;1;:: :;Nt 1: (4.6)
This scheme isknownas theForward Euler scheme, alsocalledEuler’smethod.
Inour specialpopulationgrowthmodel,wehave
unC1 DunC trun; u0 DU0; nD0;1;:: :;Nt 1: (4.7)
Wemayalsowrite thismodel using theproblem-specific symbolN insteadof the
genericu function:
NnC1 DNnC trNn; N0 DN0; nD0;1;:: :;Nt 1: (4.8)
The observant reader will realize that (4.8) is nothing but the computational
model (4.2) arising directly in the model derivation. The formula (4.8) arises,
however, fromadetour via a differential equation and anumericalmethod for the
differential equation. This looks rather unnecessary! The reasonwhywebother to
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