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

Seite - 102 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Bild der Seite - 102 -

Bild der Seite - 102 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Text der Seite - 102 -

102 4 SolvingOrdinaryDifferentialEquations Fig.4.3 Thenumerical solution at points can be extended by linear segments between themesh points derive thedifferential equationmodel and thendiscretize it byanumericalmethod is simply that the discretization can be done in many ways, and we can create (much) more accurate andmore computationally efficient methods than (4.8) or (4.6). This can be useful in many problems! Nevertheless, the Forward Euler scheme is intuitiveandwidelyapplicable, at leastwhen t is chosen tobesmall. Thenumericalsolutionbetweenthemeshpoints Ournumericalmethodcomputestheunknownfunctionuatdiscretemeshpoints t1;t2;: : :;tNt . What ifwewant to evaluate the numerical solution between the mesh points? Themost natural choice is to assume a linear variation between themeshpoints, seeFig.4.3. This is compatiblewith the fact thatwhenweplot thearrayu0;u1;:: :versus t0;t1;: : :, astraight line isdrawnbetween thediscrete points. 4.1.3 ProgrammingtheForwardEulerScheme;theSpecialCase Letuscompute(4.8) inaprogram.The inputvariablesareN0, t,r, andNt. Note that we need to computeNt C1 new valuesN1;:::;NNtC1. A total ofNt C2 valuesareneeded inanarray representationofNn,nD0;:: :;Nt C1. Ourfirstversionof thisprogramis as simpleaspossible: N_0 = input(’Give initial population size N_0: ’) r = input(’Give net growth rate r: ’) dt = input(’Give time step size: ’) N_t = input(’Give number of steps: ’) from numpy import linspace, zeros t = linspace(0, (N_t+1)*dt, N_t+2) N = zeros(N_t+2)
zurück zum  Buch Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python"
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
Web-Books
Bibliothek
Datenschutz
Impressum
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python