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 - 277 -
  • Benutzer
  • Version
    • Vollversion
    • Textversion
  • Sprache
    • Deutsch
    • English - Englisch

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

Bild der Seite - 277 -

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

Text der Seite - 277 -

8.6 Exercises 277 Exercise8.13:Use aCrank-NicolsonScheme forPopulationGrowth It is recommendedtodoExercise8.12prior to thepresentone.Herewe lookat the same population growth modelN′(t) = rN(t), N(0) = N0. The time derivative N′(t) can be approximated by various types of finite differences. Exercise 8.12 considersabackwarddifference(Fig.8.22),whileSect.8.2.2explainedtheforward difference (Fig. 8.4). A centered difference is more accurate than a backward or forwarddifference: N′(tn+ 12Δt)≈ N(tn+Δt)−N(tn) Δt = N n+1 −Nn Δt . This type of difference, applied at the point tn+12 = tn + 1 2Δt, is illustrated geometrically inFig.8.23. a) Insert the finite difference approximation in the ODE N′ = rN and solve for the unknownNn+1, assumingNn is already computed and hence known. The resultingcomputationalschemeisoftenreferredtoasaCrank-Nicolsonscheme. b) Implement the algorithm in a) in a function growth_CN(N_0, dt, T) for solvingN′ = rN,N(0)=N0, t∈ (0,T],with timestepΔt (dt). c) Make plots for comparing the Crank-Nicolson scheme with the Forward and BackwardEuler schemes in thesame test problemas inExercise8.12. Filename:growth_CN.py. Exercise8.14:Understand FiniteDifferencesviaTaylorSeries TheTaylor series arounda pointx=a can fora functionf(x)bewritten f(x)=f(a)+ d dx f(a)(x−a)+ 1 2! d2 dx2 f(a)(x−a)2 + 1 3! d3 dx3 f(a)(x−a)3+ . . . = ∞∑ i=0 1 i! di dxi f(a)(x−a)i . For a functionof time, as addressed in our ODE problems,we woulduseu instead off , t insteadofx, anda timepoint tn insteadofa: u(t)=u(tn)+ d dt u(tn)(t− tn)+ 1 2! d2 dt2 u(tn)(t− tn)2 + 1 3! d3 dt3 u(tn)(t− tn)3+ . . . = ∞∑ i=0 1 i! di dti u(tn)(t− tn)i .
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