Web-Books
in the Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
Page - 216 -
  • User
  • Version
    • full version
    • text only version
  • Language
    • Deutsch - German
    • English

Page - 216 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition

Image of the Page - 216 -

Image of the Page - 216 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition

Text of the Page - 216 -

216 8 SolvingOrdinaryDifferentialEquations orwithf(u,t)= ru inourspecial modelproblemforpopulationgrowth, un+1 −un Δt = run . (8.4) If r dependson time,we insert r(tn)= rn for r in this latter equation. The fourth step is to derive a computational algorithm. Looking at (8.3), we realize that if un should be known, we can easily solve with respect to un+1 to geta formula foruat thenext time level tn+1: un+1 =un+Δtf(un,tn). (8.5) Providedwehaveaknownstartingvalue,u0 =U0,wecanuse (8.5) toadvancethe solutionbyfirst computingu1 fromu0, thenu2 fromu1,u3 fromu2, andso forth. Suchanalgorithmiscalledanumericalscheme for thedifferentialequation. It is oftenwrittencompactlyas un+1 =un+Δtf(un,tn), u0 =U0, n=0,1,.. .,Nt −1 . (8.6) This scheme isknownas the ForwardEulerscheme, alsocalledEuler’smethod. Inourspecial populationgrowthmodel,we have un+1 =un+Δtrun, u0 =U0, n=0,1,.. .,Nt −1 . (8.7) We may also write this model using the problem-specific symbolN instead of the genericu function: Nn+1 =Nn+ΔtrNn, N0 =N0, n=0,1,.. .,Nt −1 . (8.8) The observant reader will realize that (8.8) is nothing but the computational model (8.2) arising directly in the model derivation. The formula (8.8) arises, however, from a detour via a differential equation and a numerical method for the differential equation. This looks rather unnecessary! The reason why we bother to derivethedifferentialequationmodelandthendiscretizeitbyanumericalmethodis simply that the discretizationcan be done in manyways, and we can create (much) moreaccurateandmorecomputationallyefficient methods than (8.8)or (8.6).This canbeuseful inmanyproblems!Nevertheless,theForwardEulerschemeisintuitive andwidelyapplicable, at least whenΔt is chosen to besmall. The numerical solutionbetween themesh points Our numerical method computes the unknown function u at discrete mesh points t1,t2,.. .,tNt . What if we want to evaluate the numerical solution between the mesh points? The most natural choice is to assume a linear variation between the mesh points, see Fig. 8.5. This is compatible with the fact that when we plot the arrayu0,u1,.. .versus t0,t1,.. ., a straight line is automaticallydrawnbetweenthediscretepoints (unlesswespecifyotherwise in theplotcommand).
back to the  book Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
Title
Programming for Computations – Python
Subtitle
A Gentle Introduction to Numerical Simulations with Python 3.6
Volume
Second Edition
Authors
Svein Linge
Hans Petter Langtangen
Publisher
Springer Open
Date
2020
Language
English
License
CC BY 4.0
ISBN
978-3-319-32428-9
Size
17.8 x 25.4 cm
Pages
356
Keywords
Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
Category
Informatik
Web-Books
Library
Privacy
Imprint
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python