Page - 255 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
Image of the Page - 255 -
Text of the Page - 255 -
8.4 Oscillating1DSystems:ASecondOrderODE 255
Fig. 8.27 The last 10 of 40 periods of oscillationsby the fourth-order Runge-Kutta method
Implementation The stages in the fourth-order Runge-Kutta method can easily
be implemented as a modification of the osc_Heun.py code. Alternatively,
one can use the osc_odespy.py code by just providing the argument
odespy_methods=[odespy.RK4] to thecompare function.
Derivation The derivation of the fourth-order Runge-Kutta method can be pre-
sented in a pedagogical way that brings many fundamental elements of nu-
merical discretization techniques together. It also illustrates many aspects of
the “numerical thinking” required for constructing approximate solution meth-
ods.
We start with integrating thegeneralODEu′ =f(u,t)overa timestep, from tn
to tn+1,
u(tn+1)−u(tn)= tn+1∫
tn f(u(t),t)dt .
Thegoalofthecomputationisu(tn+1) (writtenun+1),whileu(tn) (writtenun) is the
mostrecentlyknownvalueofu.Thechallengewith theintegral is that the integrand
involves the unknownubetween tn and tn+1.
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