Web-Books
in the Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Page - 128 -
  • User
  • Version
    • full version
    • text only version
  • Language
    • Deutsch - German
    • English

Page - 128 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Image of the Page - 128 -

Image of the Page - 128 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Text of the Page - 128 -

128 4 SolvingOrdinaryDifferentialEquations getu1 D2,v1 D 1:25663706,u2 D1:80260791, andv2 D 2:51327412. Such calculations show that the program is seemingly correct. (Later, we can use such values toconstruct aunit test andacorrespondingtest function.) Thenext step is to reduce the discretization parameter t and see if the results becomemore accurate. Figure 4.17 shows the numerical and exact solution for the cases t D P=40;P=160;P=2000. The results clearly become better, and the finest resolution gives graphs that cannot be visually distinguished. Neverthe- less, the finest resolution involves 6000 computational intervals in total, which is considered quitemuch. This is no problemon amodern laptop, however, as the computations take just a fractionofa second. Although 2000 intervals per oscillation period seem sufficient for an accurate numerical solution, the lower rightgraph inFig. 4.17 shows that ifwe increase the simulation time, here to20periods, there is a little growthof the amplitude,which becomes significant over time. The conclusion is that the Forward Eulermethod has a fundamental problemwith its growing amplitudes, and that a very small t is required to achieve satisfactory results. The longer the simulation is, the smaller t has tobe. It is certainly time to lookformoreeffectivenumericalmethods! Fig.4.17 Simulation of an oscillating systemwith different time steps. Upper left: 40 steps per oscillation period. Upper right: 160 steps per period. Lower left: 2000 steps per period. Lower right: 2000 stepsperperiod, but longer simulation
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
Web-Books
Library
Privacy
Imprint
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python