Seite - 129 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Bild der Seite - 129 -
Text der Seite - 129 -
4.3 OscillatingOne-DimensionalSystems 129
4.3.4 AMagicFixoftheNumericalMethod
In theForwardEuler scheme,
unC1 DunC tvn;
vnC1 Dvn t!2un;
we can replaceun in the last equation by the recently computed valueunC1 from
thefirst equation:
unC1 DunC tvn; (4.49)
vnC1 Dvn t!2unC1 : (4.50)
Beforejustifyingthisfixmoremathematically, letus tryitonthepreviousexam-
ple. TheresultsappearinFig.4.18.Weseethattheamplitudedoesnotgrow,butthe
phase is not entirely correct. After 40periods (Fig. 4.18 right)we see a significant
differencebetween thenumerical and theexact solution. Decreasing t decreases
the error. For example,with 2000 intervals per period,we only see a small phase
errorevenafter50,000periods (!).Wecansafelyconclude that thefixresults inan
excellentnumericalmethod!
Letusinterprettheadjustedschememathematically. Firstweorder(4.49)–(4.50)
such that thedifferenceapproximations toderivativesbecometransparent:
unC1 un
t Dvn; (4.51)
vnC1 vn
t D !2unC1 : (4.52)
We interpret (4.51) as the differential equation sampled atmesh point tn, because
wehavevnontheright-handside. Theleft-handside is thena forwarddifferenceor
ForwardEuler approximation to thederivativeu0, seeFig. 4.2. On the other hand,
weinterpret (4.52)as thedifferentialequationsampledatmeshpoint tnC1, sincewe
Fig.4.18 Adjustedmethod: first threeperiods (left)andperiod36–40 (right)
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