Web-Books
im Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Seite - 222 -
  • Benutzer
  • Version
    • Vollversion
    • Textversion
  • Sprache
    • Deutsch
    • English - Englisch

Seite - 222 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition

Bild der Seite - 222 -

Bild der Seite - 222 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition

Text der Seite - 222 -

222 8 SolvingOrdinaryDifferentialEquations Thecorrespondingdifferentialequationbecomes N′ = r(N)N . Thereaderisstronglyencouragedtorepeatthestepsin thederivationoftheForward Euler schemeandestablish thatwe get Nn+1 =Nn+Δtr(Nn)Nn, whichcomputesaseasy as fora constant r, since r(Nn) is knownwhencomputing Nn+1.Alternatively,onecanuse theForwardEulerformulafor thegeneralproblem u′ =f(u,t)andusef(u,t)= r(u)uand replaceubyN. Thesimplestchoiceofr(N) isa linearfunction,startingwithsomegrowthvalue r¯ and declininguntil the populationhas reached its maximum,M, according to the available resources: r(N)= r¯(1−N/M). In the beginning, N M and we will have exponential growth er¯t, but as N increases, r(N) decreases, and whenN reachesM, r(N)= 0 so there is no more growth and the population remains atN(t)=M. This linear choice of r(N)gives rise to a model that is called the logistic model. The parameterM is known as the carryingcapacityof thepopulation. Letusrunthelogisticmodelwithaidoftheode_FEfunction.WechooseN(0)= 100, Δt = 0.5 month, T = 60 months, r = 0.1, and M = 500. The complete program,calledlogistic.py, is basicallya call toode_FE: from ode_FE import ode_FE import matplotlib.pyplot as plt for dt, T in zip((0.5, 20), (60, 100)): u, t = ode_FE(f=lambda u, t: 0.1*(1 - u/500.)*u, \ U_0=100, dt=dt, T=T) plt.figure() # Make separate figures for each pass in the loop plt.plot(t, u, ’b-’) plt.xlabel(’t’); plt.ylabel(’N(t)’) plt.savefig(’tmp_{:g}.png’.format(dt)) plt.savefig(’tmp_{:g}.pdf’.format(dt)) Figure8.9showstheresultingcurve.Weseethat thepopulationstabilizesaround M = 500 individuals. A corresponding exponential growth would reachN0ert = 100e0.1·60 ≈40,300individuals! What happens if we use “large” Δt values here? We may set Δt = 20 and T = 100. Now the solution, seen in Fig. 8.10, oscillates and is hence qualitatively wrong,because one can prove that the exact solution of the differential equation is monotone.
zurück zum  Buch Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition"
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
Web-Books
Bibliothek
Datenschutz
Impressum
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python