Seite - 215 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Bild der Seite - 215 -
Text der Seite - 215 -
8.2 PopulationGrowth:AFirstOrderODE 215
is constant.Thisproperty implies that
tn=nΔt, n=0,1,.. .,Nt .
Second, the differential equation is supposed to hold at the mesh points. Note that
this is an approximation,because the differential equation is originallyvalid for all
realvaluesof t. We canexpress thispropertymathematicallyas
u′(tn)=f(un,tn), n=0,1,.. .,Nt .
Forexample,withourmodelequationu′ = ru,we have thespecial case
u′(tn)= run, n=0,1,.. .,Nt,
or
u′(tn)= r(tn)un, n=0,1,.. .,Nt,
if r dependsexplicitlyon t.
Third, derivatives are to be replaced by finite differences. To this end, we
need to know specific formulas for how derivatives can be approximated by finite
differences.Onesimplepossibility is touse thedefinitionof thederivativefromany
calculusbook,
u′(t)= lim
Δt→0 u(t+Δt)−u(t)
Δt .
Atanarbitrarymeshpoint tn thisdefinitioncanbewrittenas
u′(tn)= lim
Δt→0 un+1 −un
Δt .
Instead of going to the limit Δt → 0 we can use a small Δt, which yields a
computableapproximationtou′(tn):
u′(tn)≈ u n+1 −un
Δt .
This isknownasa forwarddifferencesincewe goforward in time(un+1) tocollect
information inu to estimate the derivative.Figure 8.4 illustrates the idea.The error
of the forwarddifference isproportional toΔt (oftenwrittenasO(Δt), butwewill
notuse thisnotation in thepresentbook).
We can now plug in the forward difference in our differential equation sampled
at thearbitrarymeshpoint tn:
un+1−un
Δt =f(un,tn), (8.3)
Programming for Computations – Python
A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
- Titel
- Programming for Computations – Python
- Untertitel
- A Gentle Introduction to Numerical Simulations with Python 3.6
- Band
- Second Edition
- Autoren
- Svein Linge
- Hans Petter Langtangen
- Verlag
- Springer Open
- Datum
- 2020
- Sprache
- englisch
- Lizenz
- CC BY 4.0
- ISBN
- 978-3-319-32428-9
- Abmessungen
- 17.8 x 25.4 cm
- Seiten
- 356
- Schlagwörter
- Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
- Kategorie
- Informatik