Page - 129 - in Programming for Computations β Python - A Gentle Introduction to Numerical Simulations with Python
Image of the Page - 129 -
Text of the Page - 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)
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