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

Page - 96 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Image of the Page - 96 -

Image of the Page - 96 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Text of the Page - 96 -

96 4 SolvingOrdinaryDifferentialEquations tionmotivates theneedforothersolutionmethods,andwederive theEuler-Cromer scheme1, the2nd-and4th-orderRunge-Kuttaschemes,aswellasafinitedifference scheme (the latter tohandle the second-orderdifferential equationdirectlywithout reformulating it as a first-order system). The presentation starts with undamped freeoscillationsand then treatsgeneraloscillatorysystemswithpossiblynonlinear damping, nonlinear spring forces, and arbitrary external excitation. Besides de- veloping programs from scratch, we also demonstrate how to access ready-made implementationsofmoreadvanceddifferential equationsolvers inPython. Aswe progress withmore advancedmethods, we developmore sophisticated and reusable programs, and inparticular,we incorporategood testing strategies so thatwebring solid evidence to correct computations. Consequently, thebeginning with populationgrowth anddiseasemodeling examples has a verygentle learning curve,while that curve gets significantly steeper towards the end of the treatment ofdifferential equations foroscillatory systems. 4.1 PopulationGrowth Ourfirst taste of differential equations regardsmodeling the growth of somepop- ulation, such as a cell culture, an animal population, or a humanpopulation. The ideas evenextend trivially to growthofmoney in a bank. LetN.t/be the number of individuals in thepopulationat time t. Howcanwepredict theevolutionofN.t/ in time? Belowweshall deriveadifferential equationwhose solution isN.t/. The equation reads N 0.t/D rN.t/; (4.1) wherer is anumber.Note thatalthoughN is an integer in real life,wemodelN as a real-valued function.Weare forced todo thisbecause the solutionofdifferential equationsare (normallycontinuous) real-valued functions.An integer-valuedN.t/ in themodelwould lead toa lotofmathematicaldifficulties. With a bit of guessing, youmay realize thatN.t/ D Cert, whereC is any number. Tomake this solution unique,we need to fixC, done byprescribing the value ofN at some time, usually t D 0. SayN.0/ is given asN0. ThenN.t/ D N0e rt. Ingeneral, adifferentialequationmodelconsists ofadifferential equation, such as (4.1) and an initial condition, such asN.0/ D N0. With a known initial con- dition, the differential equation can be solved for the unknown function and the solution isunique. It is, of course, very seldomthatwecanfind the solutionof adifferential equa- tion as easy as in this example. Normally, one has to apply certainmathematical methods, but these can only handle some of the simplest differential equations. However,wecaneasily dealwith almost anydifferential equationbyapplyingnu- mericalmethodsandabit of programming. This is exactly the topicof thepresent chapter. 1The term scheme is usedas synonymformethodor computational recipe, especially in the con- textofnumericalmethods fordifferential equations.
back to the  book Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python
Title
Programming for Computations – Python
Subtitle
A Gentle Introduction to Numerical Simulations with Python
Authors
Svein Linge
Hans Petter Langtangen
Publisher
Springer Open
Date
2016
Language
English
License
CC BY-NC 4.0
ISBN
978-3-319-32428-9
Size
17.8 x 25.4 cm
Pages
248
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