Seite - 130 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Bild der Seite - 130 -
Text der Seite - 130 -
130 4 SolvingOrdinaryDifferentialEquations
haveunC1 on the right-handside. In this case, thedifferenceapproximationon the
left-handside is abackwarddifference,
v0.tnC1/ v nC1 vn
t or v0.tn/ v n vn 1
t :
Figure 4.19 illustrates the backward difference. The error in the backward differ-
ence is proportional to t, the sameas for the forwarddifference (but the propor-
tionality constant in the error termhas different sign). The resultingdiscretization
methodfor (4.52) isoften referred toasaBackwardEuler scheme.
To summarize, using a forwarddifference for thefirst equation andabackward
difference for the second equation results in amuchbettermethod than just using
forwarddifferences inbothequations.
Thestandardwayofexpressing this scheme inphysics is tochange theorderof
theequations,
v0 D !2u; (4.53)
u0 Dv; (4.54)
andapplya forwarddifference to (4.53)andabackwarddifference to (4.54):
vnC1 Dvn t!2un; (4.55)
unC1 DunC tvnC1 : (4.56)
That is, first the velocity v is updated and then the positionu, using themost re-
centlycomputedvelocity. There isnodifferencebetween(4.55)–(4.56)and(4.49)–
(4.50)with respect to accuracy, so the order of the original differential equations
does not matter. The scheme (4.55)–(4.56) goes under the names Semi-implicit
Euler4 or Euler-Cromer. The implementation of (4.55)–(4.56) is found in the file
osc_EC.py. Thecoreof thecodegoes like
Fig.4.19 Illustrationofabackward differenceapproximation to thederivative
4http://en.wikipedia.org/wiki/Semi-implicit_Euler_method
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