Seite - 238 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Bild der Seite - 238 -
Text der Seite - 238 -
238 8 SolvingOrdinaryDifferentialEquations
Fig. 8.15 The effect ofvaccination:p=0.0005
Fig. 8.16 The effect ofvaccination:p=0.0001
is usually quite a challenge in mathematics, but as long as we solve the equations
numerically ina program,adiscontinuouscoefficient is easy to treat.
There are two ways to implement the discontinuous coefficientp(t): through a
functionand throughanarray.The functionapproachisperhaps theeasiest:
def p(t):
return 0.005 if (6*24 <= t <= 15*24) else 0
Note the handyif-else construction in the return statement here. It is a one-line
alternative to, forexample,
if (6*24 <= t <= 15*24):
return 0.005
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